:root {
  color-scheme: dark;
  color: #fff8f3;
  background: #191410;
  font: 16px/1.5 system-ui, sans-serif;
  --panel: #261d17;
  --border: #4b3b30;
  --muted: #ccbeb5;
  --orange: #ffc8a4;
  --green: #c4f18d;
  --pink: #ffa3bc;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 290px; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.page { width: min(1120px, calc(100% - 48px)); margin-inline: auto; }
.top { border-bottom: 1px solid #382d25; }
.header { display: flex; min-height: 73px; align-items: center; justify-content: flex-end; }
.brand-dot { color: var(--orange); }
.wallet, .reward {
  background: #362920;
  color: #ffe9db;
  border: 1px solid #664c3b;
  border-radius: 30px;
  padding: 7px 13px;
  white-space: nowrap;
  font-size: .85rem;
}
.wallet [aria-hidden], .reward [aria-hidden] { color: var(--orange); margin-right: 3px; }
.wallet-label { margin-right: 5px; color: var(--muted); }
.wallet small { color: var(--muted); font-size: .82rem; }

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 43px;
  padding: 8px 15px;
  font-size: .93rem;
  font-weight: 750;
  border: 1px solid transparent;
  border-radius: 9px;
  text-decoration: none;
  text-align: center;
}
.primary { background: var(--orange); color: #322014; }
.primary:hover:enabled, a.primary:hover { background: #ffdfca; }
.secondary { background: #33261d; border-color: #70533f; color: #ffeee2; }
.secondary:hover { background: #4b3526; border-color: #bc9174; }
.button:disabled { opacity: .48; }

.section { margin-top: 38px; scroll-margin-top: 14px; }
.section-head { display: flex; gap: 14px; justify-content: space-between; align-items: end; margin-bottom: 15px; }
.section h1 { font-size: clamp(1.7rem, 4vw, 2.45rem); line-height: 1.12; letter-spacing: -.045em; }
.section-head p { color: var(--muted); margin-top: 6px; }
.quiz {
  padding: clamp(17px, 3vw, 30px);
  border: 1px solid var(--border);
  border-radius: 17px;
  background: linear-gradient(130deg, #33251c, var(--panel) 70%);
}
.quiz-meta { display: flex; gap: 14px; justify-content: space-between; align-items: center; color: var(--orange); font-size: .88rem; font-weight: 700; }
progress { appearance: none; width: min(30%, 164px); height: 7px; color: var(--orange); accent-color: var(--orange); }
progress::-webkit-progress-bar { background: #5d4636; border-radius: 7px; }
progress::-webkit-progress-value { background: var(--orange); border-radius: 7px; }
progress::-moz-progress-bar { background: var(--orange); border-radius: 7px; }
.quiz h2 { margin-top: 8px; font-size: clamp(1.15rem, 3.2vw, 1.65rem); }
.answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 14px; }
.answers button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  min-height: 48px;
  color: #fff4ed;
  text-align: left;
  background: #231b15;
  border: 1px solid #584538;
  border-radius: 9px;
}
.answers button span { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 5px; background: #4b3628; color: #ffe2ce; font-size: .8rem; }
.answers button:hover:enabled { border-color: var(--orange); background: #412e22; }
.answers button[data-tone="win"], .cell[data-tone="win"] { border-color: #84aa63; color: var(--green); }
.answers button[data-tone="loss"], .cell[data-tone="loss"] { border-color: #a95672; color: var(--pink); }
.feedback { color: var(--muted); margin-top: 11px; }
.feedback:empty { margin: 0; }
.feedback[data-tone="win"] { color: var(--green); }
.feedback[data-tone="loss"] { color: var(--pink); }
.quiz-bottom button { margin-top: 10px; }

.catalog { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.game-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--panel); }
.card-copy { display: flex; flex-direction: column; align-items: flex-start; flex: 1; padding: 15px; }
.card-copy h2 { font-size: 1.16rem; }
.card-copy p { margin: 5px 0 13px; color: var(--muted); font-size: .94rem; }
.card-copy .button { margin-top: auto; }
.game-art { display: grid; place-items: center; position: relative; isolation: isolate; height: 145px; overflow: hidden; }
.game-art::before { content: ""; z-index: -1; position: absolute; inset: 0; opacity: .28; background: radial-gradient(circle at center, #ffffff 0 1px, transparent 2px) center / 28px 28px; mask-image: radial-gradient(ellipse, black, transparent 80%); }
.flight-art { background: radial-gradient(ellipse at center, #713e37, #32251d 74%); }
.crystal-art { background: radial-gradient(ellipse at center, #835333, #332319 74%); }
.cards-art { background: radial-gradient(ellipse at center, #704f39, #2a2019 74%); }
.orbit { position: absolute; width: 66%; height: 46%; border: 1px solid #fff3; border-radius: 50%; transform: rotate(-17deg); }
.art-airship { position: relative; width: 145px; height: 54px; margin-top: -6px; border-radius: 67% 57% 59% 61%; transform: rotate(-14deg); background: linear-gradient(#ffe9a7, #e99464 64%, #a75662); box-shadow: inset 0 1px 5px #fff, 0 9px 23px #180e07a0; }
.art-airship::before { content: ""; position: absolute; inset: 9px 1px; border-block: 1px solid #904b50a0; border-radius: 50%; }
.art-airship::after { content: ""; position: absolute; top: 18px; left: -12px; width: 26px; height: 18px; background: #d48462; clip-path: polygon(0 0, 100% 32%, 100% 70%, 0 100%); }
.art-airship i { position: absolute; top: 48px; left: 54px; width: 43px; height: 14px; border-top: 3px solid #e8ad80; border-radius: 0 0 14px 14px; background: #a95f70; }
.gem { width: 85px; aspect-ratio: 1; transform: rotate(-9deg); clip-path: polygon(20% 5%, 77% 5%, 100% 39%, 50% 100%, 0% 39%); background: conic-gradient(from 25deg at 50% 40%, #ffe4d2 0 16%, #ffad76 16% 28%, #c46f37 28% 47%, #f8aa76 47% 65%, #ffe0cb 65% 78%, #ffbf94 78% 100%); }
.gem-side { position: absolute; margin: 27px 0 0 90px; width: 38px; transform: rotate(20deg); opacity: .8; }
.art-card { display: grid; place-items: center; position: absolute; width: 55px; height: 76px; border-radius: 7px; font-size: 1.7rem; box-shadow: 0 2px 9px #170e0855; }
.back-card { transform: translateX(-23px) rotate(-17deg); border: 3px solid #efccb4; color: #efccb4; background: #a46f4c; }
.front-card { transform: translateX(18px) rotate(13deg); background: #fff0ef; color: #ad3b61; border: 3px solid #fff9f9; }
.footer { display: flex; justify-content: space-between; margin-block: 34px 22px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: .86rem; }

dialog { border: 1px solid #735745; border-radius: 16px; width: min(490px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; color: inherit; background: var(--panel); }
dialog::backdrop { background: #150d08d4; }
.dialog-inner { padding: 20px; }
.dialog-header { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.dialog-header h2 { font-size: 1.65rem; }
#close-game { border: 1px solid var(--border); color: inherit; background: #382a20; min-width: 41px; min-height: 41px; border-radius: 8px; font-size: 1.3rem; }
.dialog-wallet { color: var(--orange); margin: 4px 0 12px; }
#wager-form label, .dialog-note { color: var(--muted); font-size: .9rem; }
.wager-row, .card-choices { display: flex; gap: 8px; margin-block: 6px 10px; }
.wager-row input { min-width: 0; width: 100%; color: inherit; background: #1e1712; border: 1px solid #735745; border-radius: 8px; padding-inline: 8px; }
.wager-row button { flex: 0 0 auto; }
#earn-link { display: inline-block; margin-top: 10px; color: var(--orange); }
.crystal-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 305px; gap: 6px; margin: 13px auto; }
.cell { aspect-ratio: 1; color: var(--orange); background: #402d21; border: 1px solid #735745; border-radius: 8px; font-size: 1.35rem; }
.cell:hover:enabled { background: #5b4130; }
#game-field > .button { width: 100%; }
.cards-field { display: flex; justify-content: center; gap: 12px; margin: 14px auto; }
.cards-field span { display: grid; place-items: center; width: 76px; height: 104px; background: #ffeef5; color: #a0325a; border-radius: 9px; font-size: 1.7rem; font-weight: 800; }
.cards-field span + span { background: #774f34; color: #ffe6d5; }
.card-choices .button { flex: 1; }

@media (max-width: 900px) {
  .catalog { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .page { width: calc(100% - 24px); }
  .header { min-height: 57px; }
  .wallet { padding: 5px 8px; }
  .section { margin-top: 24px; }
  .reward { display: none; }
}
@media (max-width: 540px) {
  .catalog, .answers { grid-template-columns: 1fr; }
}

.game-history {
  margin-top: 20px;
  padding: clamp(13px, 3vw, 22px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
}
.game-history h2 { margin-bottom: 8px; }
.game-history p, .game-history time { color: var(--muted); font-size: .88rem; }
.game-history ol { margin: 0; padding: 0; list-style: none; }
.game-history li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 5px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.game-history time { display: block; }
#game-history-more { margin-top: 12px; }
