:root {
  --bg: #0a1025;
  --panel: rgba(21, 30, 64, .86);
  --panel-border: rgba(255, 255, 255, .13);
  --text: #f8f7ff;
  --muted: #a8b1d3;
  --cyan: #79e6e7;
  --lavender: #a995ff;
  --peach: #ffae87;
  --yellow: #f9d779;
  --shadow: 0 24px 80px rgba(0, 0, 0, .34);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 5%, rgba(169, 149, 255, .17), transparent 26rem),
    radial-gradient(circle at 92% 15%, rgba(121, 230, 231, .11), transparent 24rem),
    var(--bg);
}

button { font: inherit; }
button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.app-shell { width: min(100% - 32px, 700px); margin: 0 auto; padding: 28px 0 26px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 8px; color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 6vw, 42px); line-height: 1; letter-spacing: -.07em; }

.sound-button {
  display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center;
  border: 1px solid var(--panel-border); border-radius: 50%; color: var(--text);
  background: rgba(255, 255, 255, .07); cursor: pointer; transition: .2s ease;
}
.sound-button:hover { border-color: var(--cyan); transform: translateY(-2px); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 12px; }
.stat-card { padding: 10px 12px; border: 1px solid var(--panel-border); border-radius: 15px; background: var(--panel); box-shadow: var(--shadow); }
.stat-card span { display: block; color: var(--muted); font-size: 10px; letter-spacing: .06em; }
.stat-card strong { display: block; margin-top: 2px; color: var(--text); font-size: clamp(18px, 4vw, 24px); }

.game-card { overflow: hidden; border: 1px solid rgba(255, 255, 255, .14); border-radius: 26px; background: var(--panel); box-shadow: var(--shadow); }
.board-wrap { position: relative; min-height: 470px; padding: clamp(18px, 4vw, 30px); background: linear-gradient(145deg, #18234b, #101832 58%, #0d142d); isolation: isolate; }
.board-wrap::before, .board-wrap::after { position: absolute; z-index: -1; border: 1px solid rgba(121, 230, 231, .14); border-radius: 50%; content: ""; }
.board-wrap::before { width: 360px; height: 360px; top: -160px; right: -130px; }
.board-wrap::after { width: 250px; height: 250px; bottom: -170px; left: -120px; border-color: rgba(169, 149, 255, .13); }

.board {
  display: grid;
  width: min(100%, 560px);
  aspect-ratio: 1;
  margin: 0 auto;
  padding: 10px;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 22px;
  background: rgba(5, 10, 28, .44);
  box-shadow: inset 0 1px rgba(255, 255, 255, .09), 0 20px 45px rgba(0, 0, 0, .2);
}

.arrow-tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px;
  color: var(--text);
  background: linear-gradient(145deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .035));
  box-shadow: inset 0 1px rgba(255, 255, 255, .08), 0 7px 12px rgba(0, 0, 0, .13);
  cursor: pointer;
  touch-action: manipulation;
  transition: background .16s ease, border-color .16s ease, transform .16s ease, opacity .16s ease;
}

.arrow-glyph { display: block; color: var(--arrow-color, var(--cyan)); font-size: clamp(22px, 5vw, 34px); font-weight: 800; line-height: 1; text-shadow: 0 0 16px color-mix(in srgb, var(--arrow-color, var(--cyan)) 46%, transparent); transition: transform .16s ease; }
.arrow-tile:hover { border-color: rgba(255, 255, 255, .42); background: rgba(255, 255, 255, .13); transform: translateY(-2px); }
.arrow-tile:active { transform: scale(.92); }
.arrow-tile.is-blocked { border-color: var(--peach); animation: shake .24s ease; }
.arrow-tile.is-flying { z-index: 3; opacity: 0; transform: translate(var(--fly-x), var(--fly-y)) scale(.3) rotate(18deg); transition: transform .27s cubic-bezier(.2, .75, .2, 1), opacity .27s ease; pointer-events: none; }
.arrow-tile.is-gone { visibility: hidden; }

@keyframes shake { 0%, 100% { transform: translateX(0); } 30% { transform: translateX(-5px); } 70% { transform: translateX(5px); } }

.toast { position: absolute; left: 50%; bottom: 21px; padding: 9px 13px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 999px; color: var(--muted); background: rgba(9, 14, 35, .72); font-size: 12px; opacity: 0; pointer-events: none; transform: translate(-50%, 8px); transition: .2s ease; white-space: nowrap; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.screen { position: absolute; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(7, 11, 29, .51); opacity: 0; pointer-events: none; transition: opacity .24s ease; }
.screen.is-visible { opacity: 1; pointer-events: auto; }
.screen-card { width: min(100%, 410px); padding: clamp(24px, 6vw, 42px); border: 1px solid rgba(255, 255, 255, .16); border-radius: 24px; background: rgba(18, 26, 58, .92); box-shadow: 0 20px 60px rgba(0, 0, 0, .36); backdrop-filter: blur(18px); }

.dream-mark { display: flex; gap: 3px; margin-bottom: 22px; color: var(--cyan); font-size: 27px; font-weight: 800; }
.dream-mark span:nth-child(1) { color: var(--peach); transform: translateY(7px); }
.dream-mark span:nth-child(2) { color: var(--yellow); }
.dream-mark span:nth-child(3) { color: var(--lavender); transform: translateY(7px); }
.screen-card h2 { margin-bottom: 18px; font-size: clamp(40px, 11vw, 68px); line-height: .9; letter-spacing: -.08em; }
.screen-card h2 em { color: var(--yellow); font-style: normal; }
.screen-copy { max-width: 34ch; margin-bottom: 23px; color: var(--muted); font-size: 14px; line-height: 1.75; }

.primary-button, .secondary-button { display: flex; width: 100%; min-height: 51px; align-items: center; justify-content: space-between; padding: 0 18px; border-radius: 13px; font-weight: 800; cursor: pointer; transition: .2s ease; }
.primary-button { border: 0; color: #181629; background: var(--yellow); box-shadow: 0 12px 30px rgba(249, 215, 121, .16); }
.primary-button:hover, .primary-button:focus-visible { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(249, 215, 121, .26); }
.secondary-button { margin-top: 9px; border: 1px solid rgba(121, 230, 231, .3); color: var(--text); background: rgba(121, 230, 231, .1); }
.secondary-button:hover, .secondary-button:focus-visible { border-color: var(--cyan); background: rgba(121, 230, 231, .16); }
.best-line { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.best-line strong { color: var(--yellow); }
.win-meta { display: flex; gap: 15px; margin: 20px 0 17px; color: var(--muted); font-size: 12px; }
.win-meta b { margin-left: 3px; color: var(--text); }
.share-status { min-height: 16px; margin: 9px 0 0; color: var(--cyan); font-size: 11px; text-align: center; }

.control-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; padding: 15px 17px 17px; }
.control-row p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; text-align: center; }
.tool-button { display: grid; min-width: 60px; gap: 2px; place-items: center; padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 10px; cursor: pointer; }
.tool-button span { color: var(--cyan); font-size: 21px; line-height: 1; }
.tool-button:hover { color: var(--text); }

.how-to { display: flex; align-items: center; justify-content: center; gap: 19px; padding: 18px 0 9px; }
.how-to p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; text-align: center; }
.how-to p span { color: rgba(168, 177, 211, .67); }
.how-icon { color: var(--yellow); font-size: 14px; }
.footer-note { margin-top: 14px; color: rgba(168, 177, 211, .62); font-size: 11px; text-align: center; }

@media (max-width: 480px) {
  .app-shell { width: min(100% - 20px, 700px); padding-top: 18px; }
  .board-wrap { min-height: 460px; padding: 14px; }
  .board { padding: 7px; gap: 5px; border-radius: 17px; }
  .arrow-tile { border-radius: 9px; }
  .control-row { padding-inline: 10px; }
}

.header-actions { display: flex; align-items: center; gap: 8px; }
.settings-button { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--panel-border); border-radius: 50%; color: var(--muted); background: rgba(255, 255, 255, .06); cursor: pointer; transition: .2s ease; }
.settings-button:hover { color: var(--text); border-color: var(--cyan); transform: translateY(-2px); }

.daily-gift, .leaderboard-panel { margin-top: 14px; padding: 20px; border: 1px solid var(--panel-border); border-radius: 20px; background: var(--panel); box-shadow: var(--shadow); }
.gift-heading, .section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.gift-heading .eyebrow, .section-heading .eyebrow { margin-bottom: 5px; }
.gift-heading h2, .section-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.06em; }
.gift-badge, .scope-chip { display: inline-flex; min-height: 24px; align-items: center; padding: 0 10px; border: 1px solid rgba(249, 215, 121, .25); border-radius: 999px; color: var(--yellow); background: rgba(249, 215, 121, .08); font-size: 10px; white-space: nowrap; }
.gift-copy { margin: 13px 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.gift-items { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 13px; }
.gift-items span { padding: 8px 10px; border: 1px solid var(--panel-border); border-radius: 10px; color: var(--text); background: rgba(255, 255, 255, .05); font-size: 12px; }
.gift-items b { margin-left: 3px; color: var(--yellow); }
.gift-status { min-height: 16px; margin: 9px 0 0; color: var(--cyan); font-size: 11px; text-align: center; }

.rank-tabs { display: flex; gap: 6px; margin: 15px 0 10px; }
.rank-tab { padding: 7px 13px; border: 1px solid var(--panel-border); border-radius: 999px; color: var(--muted); background: rgba(255, 255, 255, .04); cursor: pointer; font-size: 11px; }
.rank-tab.is-active { border-color: rgba(121, 230, 231, .35); color: var(--text); background: rgba(121, 230, 231, .11); }
.leaderboard-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.leaderboard-item, .leaderboard-empty { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; min-height: 40px; padding: 0 11px; border-radius: 11px; background: rgba(255, 255, 255, .05); font-size: 12px; }
.leaderboard-item.is-top { background: rgba(249, 215, 121, .1); }
.leaderboard-rank { color: var(--yellow); font-weight: 800; }
.leaderboard-name { color: var(--text); }
.leaderboard-date { margin-left: 7px; color: var(--muted); font-size: 10px; }
.leaderboard-score { color: var(--cyan); font-size: 14px; }
.leaderboard-empty { display: block; padding: 12px; color: var(--muted); text-align: center; }
.leaderboard-note { margin: 11px 0 0; color: rgba(168, 177, 211, .68); font-size: 10px; line-height: 1.5; }

.modal { position: fixed; inset: 0; z-index: 20; display: none; place-items: center; padding: 20px; background: rgba(3, 6, 20, .66); backdrop-filter: blur(8px); }
.modal.is-open { display: grid; }
.modal-card { width: min(100%, 420px); padding: 23px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 22px; background: rgba(18, 26, 58, .96); box-shadow: 0 24px 80px rgba(0, 0, 0, .42); }
.modal-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.modal-heading h2 { margin: 0; font-size: 27px; letter-spacing: -.06em; }
.modal-close { width: 32px; height: 32px; border: 1px solid var(--panel-border); border-radius: 50%; color: var(--muted); background: rgba(255, 255, 255, .05); cursor: pointer; font-size: 21px; line-height: 1; }
.setting-row, .volume-row, .theme-section { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--panel-border); color: var(--text); font-size: 13px; }
.toggle-button { min-width: 58px; padding: 6px 10px; border: 1px solid rgba(121, 230, 231, .28); border-radius: 999px; color: var(--cyan); background: rgba(121, 230, 231, .09); cursor: pointer; font-size: 11px; }
.toggle-button[aria-pressed="false"] { border-color: var(--panel-border); color: var(--muted); background: rgba(255, 255, 255, .05); }
.volume-row input { width: 150px; accent-color: var(--cyan); }
.theme-section { display: block; }
.theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.theme-button { display: grid; gap: 6px; place-items: center; padding: 9px 6px; border: 1px solid var(--panel-border); border-radius: 12px; color: var(--muted); background: rgba(255, 255, 255, .04); cursor: pointer; font-size: 11px; }
.theme-button.is-active { border-color: var(--cyan); color: var(--text); background: rgba(121, 230, 231, .1); }
.primary-button:disabled, .secondary-button:disabled, .tool-button:disabled, .daily-gift button:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; transform: none; }
.theme-preview { display: block; width: 42px; height: 24px; border-radius: 8px; }
.theme-preview-dark { background: linear-gradient(135deg, #111a3c, #050916); }
.theme-preview-colorful { background: linear-gradient(135deg, #ff6b78, #ffd75a 45%, #5de0c7); }
.theme-preview-yarn { background: repeating-linear-gradient(135deg, #edcda8 0 4px, #d29c76 4px 7px); }

body.theme-colorful { background: radial-gradient(circle at 12% 5%, rgba(255, 107, 120, .21), transparent 25rem), radial-gradient(circle at 90% 18%, rgba(93, 224, 199, .16), transparent 24rem), #17152e; }
body.theme-colorful .board-wrap { background: linear-gradient(145deg, #3f2355, #1b2850 58%, #18253c); }
body.theme-colorful .arrow-tile { border-color: rgba(255, 255, 255, .26); }
body.theme-yarn { color: #3d2a2a; background: radial-gradient(circle at 12% 5%, rgba(243, 197, 145, .5), transparent 24rem), #e9d2b7; }
body.theme-yarn .app-shell { --text: #3d2a2a; --muted: #846b63; --panel: rgba(255, 248, 237, .72); --panel-border: rgba(98, 63, 48, .18); --bg: #e9d2b7; --cyan: #368e8d; --yellow: #c77b45; }
body.theme-yarn .game-card, body.theme-yarn .daily-gift, body.theme-yarn .leaderboard-panel { background: rgba(255, 248, 237, .76); }
body.theme-yarn .board-wrap { background: repeating-linear-gradient(125deg, #dcae86 0 5px, #edcda8 5px 10px); }
body.theme-yarn .board { background: rgba(107, 65, 49, .15); border-color: rgba(98, 63, 48, .2); }
body.theme-yarn .arrow-tile { border-color: rgba(98, 63, 48, .2); background: radial-gradient(circle at 32% 26%, rgba(255, 255, 255, .8), transparent 13%), repeating-linear-gradient(135deg, #f5cba4 0 4px, #cf8f70 4px 7px); }
body.theme-yarn .arrow-glyph { text-shadow: none; }

@media (max-width: 480px) {
  .header-actions { gap: 5px; }
  .daily-gift, .leaderboard-panel { padding: 17px; }
  .volume-row input { width: 125px; }
}
