@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@600;700;800;900&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  font-family: 'DM Sans', sans-serif;
  color: #fff8df;
  background: #183c36;
  font-synthesis: none;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible { outline: 3px solid #ffe199; outline-offset: 3px; }
#game { height: 100vh; height: 100svh; width: 100%; overflow: hidden; position: relative; isolation: isolate; }
@supports (height: 100dvh) { #game { height: 100dvh; } }
#game:fullscreen { width: 100%; height: 100%; }
#game:-webkit-full-screen { width: 100%; height: 100%; }
#world { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
#world:focus-visible { outline: 2px solid #ffe199; outline-offset: -3px; }
.vignette { position: absolute; inset: 0; background: linear-gradient(90deg,rgba(5,26,24,.78),transparent 62%),linear-gradient(0deg,rgba(4,24,21,.82),transparent 22%,transparent 78%,rgba(4,24,21,.45)); pointer-events: none; transition: opacity .6s; }
body.playing .vignette { opacity: .45; }
header { position: absolute; z-index: 4; top: calc(var(--safe-top) + 24px); left: calc(var(--safe-left) + 32px); right: calc(var(--safe-right) + 32px); display: flex; justify-content: space-between; align-items: center; gap: 12px; pointer-events: none; }
header > * { pointer-events: auto; }
.brand { display: flex; gap: 10px; align-items: center; min-height: 44px; color: #fff8df; text-decoration: none; font: 700 25px 'Barlow Condensed', sans-serif; letter-spacing: 3px; text-shadow: 0 1px 5px #092521; }
.brand b { color: #f7c164; }
.brand small { display: block; font: 600 9px 'DM Sans', sans-serif; letter-spacing: 2.2px; margin-top: 4px; }
.brand-mark { color: #f7c164; font-size: 42px; line-height: 1; }
.top-actions { display: flex; gap: 8px; }
.top-actions button { flex: 0 0 44px; color: #fff6da; border: 1px solid #a7baa0; background: #10382fec; border-radius: 50%; width: 44px; height: 44px; padding: 0; font-size: 23px; }
.top-actions button:hover:not(:disabled), .touch button:hover { background: #365847; }
#sound { position: relative; padding-bottom: 6px; }
#sound-label { position: absolute; font-size: 8px; bottom: 5px; left: 0; right: 0; }
#fullscreen[aria-pressed='true'] { color: #18382e; background: #f5bf65; border-color: #ffe4a3; }
.menu { position: absolute; left: max(7%, calc(var(--safe-left) + 24px)); top: max(calc(var(--safe-top) + 106px), 18%); bottom: calc(var(--safe-bottom) + 70px); width: 380px; max-width: calc(100% - var(--safe-left) - var(--safe-right) - 48px); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #f5bf65 #14382f; padding: 4px; }
.eyebrow { font-size: 11px; letter-spacing: 3px; color: #edc77c; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.eyebrow span { height: 1px; width: 24px; background: #edc77c; }
h1 { font: 900 clamp(86px, 17svh, 148px)/.78 'Barlow Condensed', Impact, sans-serif; letter-spacing: -3px; margin: 26px 0 24px; position: relative; text-shadow: 0 5px 35px #061c2540; }
h1 span { color: #ffc76a; }
h1 i { font: 600 18px 'Barlow Condensed', sans-serif; letter-spacing: 2px; vertical-align: top; display: inline-block; margin: 9px 0 0 13px; border-top: 1px solid #ffc76a; border-bottom: 1px solid #ffc76a; color: #ffc76a; }
p { font-size: 16px; line-height: 1.65; color: #e1e5d6; }
.menu p { margin: 0 0 16px; }
.primary { background: #f5bf65; color: #1e3029; border: 0; border-radius: 3px; padding: 17px 23px; min-height: 54px; min-width: 230px; max-width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 24px; font-size: 13px; letter-spacing: 2px; font-weight: 800; box-shadow: 0 6px 24px #0002; transition: background .2s, transform .2s; }
.primary:hover { background: #ffda93; transform: translateY(-1px); }
.primary span { font-size: 23px; line-height: 16px; }
.best { font-size: 10px; letter-spacing: 1.8px; color: #d3dbc9; margin-top: 16px; }
.best b { color: #fff4d3; margin-left: 14px; font-size: 12px; }
.creator-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0 16px; margin-top: 10px; }
.creator-links a { min-height: 44px; display: inline-flex; align-items: center; color: #fff0ce; font-size: 12px; font-weight: 600; text-decoration-color: #afbb9f; text-underline-offset: 4px; }
.creator-links a:hover { color: #ffcf7b; }
footer { position: absolute; bottom: calc(var(--safe-bottom) + 22px); left: calc(var(--safe-left) + 32px); right: calc(var(--safe-right) + 32px); display: flex; justify-content: space-between; align-items: center; gap: 16px; pointer-events: none; }
.edition { font-size: 9px; letter-spacing: 2px; color: #d4dbc8; }
.controls { display: flex; flex-wrap: wrap; gap: 16px; font-size: 11px; color: #dee5d8; }
.controls > span { display: flex; align-items: center; gap: 5px; }
kbd { font: 12px 'DM Sans', sans-serif; border: 1px solid #e3ead74d; border-radius: 3px; min-width: 22px; height: 23px; display: inline-flex; align-items: center; justify-content: center; color: #fff8df; }
.hud { position: absolute; top: calc(var(--safe-top) + 24px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 30px; padding: 5px 14px; text-align: center; background: #092f27de; border-radius: 8px; pointer-events: none; }
.hud small, #results small { display: block; font-size: 10px; letter-spacing: 2px; color: #dedac1; }
.hud strong { font: 600 36px 'Barlow Condensed', sans-serif; letter-spacing: 1px; }
.hud em { font: normal 14px 'DM Sans', sans-serif; }
.coin-count { display: flex; gap: 7px; align-items: center; color: #ffcb69; }
.coin-count > span { font-size: 28px; }
.turn-count strong { font-size: 30px; }
.overlay { position: absolute; z-index: 3; inset: 0; background: #09252199; backdrop-filter: blur(7px); display: flex; align-items: center; justify-content: center; padding: calc(var(--safe-top) + 86px) calc(var(--safe-right) + 18px) calc(var(--safe-bottom) + 18px) calc(var(--safe-left) + 18px); }
.panel { background: #123830f5; border: 1px solid #c5d7a84d; border-radius: 8px; padding: 32px; text-align: center; width: 440px; max-width: 100%; max-height: 100%; overflow: auto; overscroll-behavior: contain; box-shadow: 0 25px 100px #071d2655; scrollbar-width: thin; scrollbar-color: #f5bf65 #14382f; }
.panel .eyebrow { justify-content: center; font-size: 10px; }
h2 { font: 700 50px 'Barlow Condensed', sans-serif; margin: 16px 0 10px; }
.panel p { font-size: 14px; margin: 0; }
.panel .primary { width: 100%; margin-top: 20px; }
.panel .creator-links { justify-content: center; }
#results { display: flex; justify-content: center; gap: 45px; margin: 22px 0; }
#results b { font: 600 34px 'Barlow Condensed', sans-serif; display: block; margin-top: 6px; color: #ffcd7c; }
.hidden { display: none !important; }
.touch-hint { display: none; }
.touch { display: flex; position: absolute; bottom: calc(var(--safe-bottom) + 68px); left: 50%; transform: translateX(-50%); gap: 14px; }
.touch button { flex: 0 0 54px; width: 54px; height: 48px; padding: 0; border: 1px solid #c4cfb0; border-radius: 10px; background: #10392de8; color: #fff2cb; font-size: 26px; user-select: none; -webkit-user-select: none; }
.touch button:active { background: #f5bf65; color: #18382e; }
.turn-prompt { position: absolute; top: calc(var(--safe-top) + 120px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 18px; background: #143d34f5; border: 1px solid #e1ce8b99; border-radius: 8px; padding: 10px 18px; color: #fff1d0; box-shadow: 0 8px 30px #0003; pointer-events: none; min-width: 230px; max-width: calc(100% - var(--safe-left) - var(--safe-right) - 32px); }
.turn-prompt > strong { font-size: 42px; white-space: nowrap; line-height: 1; }
.turn-prompt b { display: block; font-size: 12px; letter-spacing: 1.3px; }
.turn-prompt span { display: block; font-size: 14px; margin-top: 4px; }
.turn-prompt.ready { background: #f5bf65; color: #18382e; border-color: #ffe4a3; box-shadow: 0 0 30px #ffca6466; }
#toast { position: absolute; top: calc(var(--safe-top) + 206px); left: 50%; transform: translateX(-50%); font-size: 11px; font-weight: 700; text-align: center; max-width: 90%; color: #ffe1a2; background: #10392deb; border-radius: 4px; padding: 8px 12px; pointer-events: none; }
#toast:empty { display: none; }
.screen-status { position: absolute; z-index: 5; right: calc(var(--safe-right) + 16px); top: calc(var(--safe-top) + 73px); max-width: min(320px, calc(100% - 32px)); margin: 0; padding: 10px 14px; border: 1px solid #9bad91; border-radius: 6px; color: #fff8df; background: #123830; font-size: 12px; pointer-events: none; }
.screen-status:empty { display: none; }

@media (max-width: 1000px) {
  .right { display: none; }
  .controls { gap: 10px; }
}
@media (max-width: 760px) {
  header { top: calc(var(--safe-top) + 16px); left: calc(var(--safe-left) + 18px); right: calc(var(--safe-right) + 18px); }
  .brand { font-size: 20px; letter-spacing: 2px; gap: 7px; }
  .brand small { font-size: 8px; letter-spacing: 1.3px; }
  .brand-mark { font-size: 34px; }
  .top-actions { gap: 6px; }
  .menu { left: calc(var(--safe-left) + 26px); top: calc(var(--safe-top) + 102px); bottom: calc(var(--safe-bottom) + 66px); width: 330px; max-width: calc(100% - var(--safe-left) - var(--safe-right) - 52px); }
  h1 { font-size: clamp(86px, 17svh, 128px); margin: 20px 0; }
  .menu p { font-size: 14px; }
  .eyebrow { font-size: 10px; letter-spacing: 2px; }
  footer { left: calc(var(--safe-left) + 22px); right: calc(var(--safe-right) + 22px); bottom: calc(var(--safe-bottom) + 16px); }
  .controls { display: none; }
  .touch-hint { display: block; font-size: 11px; color: #e2e6d7; max-width: 165px; line-height: 1.45; text-align: right; }
  .edition { max-width: 120px; font-size: 8px; line-height: 1.7; }
  .hud { top: calc(var(--safe-top) + 78px); gap: 22px; padding: 5px 14px; }
  .hud strong { font-size: 29px; }
  .turn-count strong { font-size: 26px; }
  .touch { bottom: calc(var(--safe-bottom) + 68px); left: calc(var(--safe-left) + 22px); right: calc(var(--safe-right) + 22px); transform: none; justify-content: space-between; gap: 8px; }
  .turn-prompt { top: calc(var(--safe-top) + 149px); padding: 9px 14px; }
  .turn-prompt > strong { font-size: 34px; }
  #toast { top: calc(var(--safe-top) + 228px); }
  body.playing .brand small { display: none; }
  .panel { padding: 24px; }
  h2 { font-size: 44px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  header { top: calc(var(--safe-top) + 10px); left: calc(var(--safe-left) + 18px); right: calc(var(--safe-right) + 18px); }
  .brand { font-size: 19px; }
  .brand-mark { font-size: 32px; }
  .brand small { font-size: 7px; letter-spacing: 1px; }
  body.playing .brand > span:last-child { display: none; }
  .menu { top: calc(var(--safe-top) + 74px); bottom: calc(var(--safe-bottom) + 42px); left: max(6%, calc(var(--safe-left) + 22px)); width: 660px; max-width: calc(100% - var(--safe-left) - var(--safe-right) - 64px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, 1fr); align-items: center; gap: 24px; }
  .menu .eyebrow { font-size: 9px; letter-spacing: 1.8px; }
  .menu .eyebrow span { width: 14px; }
  h1 { font-size: clamp(72px, 23svh, 110px); margin: 16px 0 10px; }
  .menu p { font-size: 13px; line-height: 1.5; margin-bottom: 10px; }
  .primary { min-height: 48px; padding: 14px 18px; font-size: 12px; }
  .best { margin-top: 10px; font-size: 9px; }
  .creator-links { margin-top: 3px; gap: 0 14px; }
  footer { bottom: calc(var(--safe-bottom) + 10px); left: calc(var(--safe-left) + 22px); right: calc(var(--safe-right) + 22px); }
  .edition, .controls { display: none; }
  .touch-hint { display: block; max-width: none; font-size: 10px; line-height: 1.4; text-align: left; }
  body.playing footer { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 14px); width: min(270px, 42%); text-align: center; }
  body.playing .touch-hint { width: 100%; text-align: center; }
  .hud { top: calc(var(--safe-top) + 8px); left: calc(var(--safe-left) + 70px); transform: none; gap: 16px; padding: 3px 12px; }
  .hud small { font-size: 8px; letter-spacing: 1px; }
  .hud strong { font-size: 27px; }
  .hud em { font-size: 11px; }
  .coin-count > span { font-size: 23px; }
  .turn-prompt { top: calc(var(--safe-top) + 72px); padding: 7px 12px; gap: 10px; min-width: 0; }
  .turn-prompt > strong { font-size: 28px; }
  .turn-prompt b { font-size: 10px; }
  .turn-prompt span { font-size: 12px; margin-top: 2px; }
  #toast { top: calc(var(--safe-top) + 132px); padding: 6px 9px; }
  .touch { bottom: calc(var(--safe-bottom) + 12px); left: calc(var(--safe-left) + 18px); right: calc(var(--safe-right) + 18px); transform: none; gap: 10px; }
  .touch button:nth-child(2) { margin-right: auto; }
  .overlay { padding: calc(var(--safe-top) + 64px) calc(var(--safe-right) + 18px) calc(var(--safe-bottom) + 10px) calc(var(--safe-left) + 18px); }
  .panel { width: 660px; padding: 18px 22px 10px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(210px, 1fr); gap: 6px 24px; align-items: center; }
  .panel .eyebrow { font-size: 9px; letter-spacing: 2px; }
  h2 { font-size: 36px; margin: 8px 0; }
  .panel p { font-size: 12px; line-height: 1.5; }
  .panel .primary { margin-top: 10px; min-width: 0; }
  .panel .creator-links { grid-column: 1 / -1; }
  #results { margin: 0; gap: 30px; }
  #results b { font-size: 28px; margin-top: 3px; }
}
@media (max-width: 360px) {
  header { left: calc(var(--safe-left) + 12px); right: calc(var(--safe-right) + 12px); gap: 7px; }
  .brand { font-size: 18px; letter-spacing: 1.5px; gap: 5px; }
  .brand small { font-size: 7px; letter-spacing: .9px; }
  .brand-mark { font-size: 30px; }
  .top-actions { gap: 5px; }
  .menu { left: calc(var(--safe-left) + 20px); max-width: calc(100% - var(--safe-left) - var(--safe-right) - 40px); }
  .creator-links { gap: 0 12px; }
  .panel { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .vignette, .primary { transition: none; }
  .primary:hover { transform: none; }
}
