* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0f1a; color: #e8ecf5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; touch-action: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }

#ui { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center;
  gap: 14px; padding: 20px max(16px, env(safe-area-inset-right)) 20px max(16px, env(safe-area-inset-left));
  overflow-y: auto; pointer-events: auto; touch-action: pan-y;
  background: radial-gradient(ellipse at 50% 20%, #1c2740 0%, #0b0f1a 70%); }
.screen.dim { background: rgba(6, 9, 16, .82); backdrop-filter: blur(3px); }

h1 { font-size: clamp(34px, 9vw, 76px); font-weight: 900; letter-spacing: .06em; line-height: .95; text-align: center;
  color: #ffd84a; text-shadow: 0 3px 0 #a3541a, 0 0 28px rgba(255, 150, 40, .45); }
h1 span { display: block; color: #ff5a3c; }
h2 { font-size: clamp(24px, 5vw, 38px); font-weight: 800; color: #ffd84a; text-align: center; }
h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .1em; color: #8fa3c8; }
.sub { color: #8fa3c8; text-align: center; font-size: 15px; max-width: 520px; }
.hint { color: #7285a8; font-size: 13px; max-width: 320px; text-align: center; }

.col { display: flex; flex-direction: column; gap: 10px; width: min(300px, 100%); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btn { font: inherit; font-weight: 700; font-size: 17px; color: #e8ecf5; background: #1f2a44; border: 2px solid #35476f;
  border-radius: 10px; padding: 12px 22px; cursor: pointer; transition: transform .08s, background .15s; }
.btn:hover { background: #2a3960; }
.btn:active { transform: scale(.97); }
.btn.primary { background: #d8452b; border-color: #ff7a4d; color: #fff; }
.btn.primary:hover { background: #ee5535; }
.btn.small { font-size: 14px; padding: 8px 14px; font-weight: 600; color: #8fa3c8; }

label { display: flex; align-items: center; gap: 10px; font-size: 15px; color: #b9c6e0; }
input, select { font: inherit; font-size: 16px; color: #fff; background: #131a2c; border: 2px solid #35476f; border-radius: 8px;
  padding: 8px 10px; width: 150px; -webkit-user-select: text; user-select: text; }
select { width: auto; }
.panel { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 20px; width: min(360px, 100%);
  background: rgba(19, 26, 44, .8); border: 1px solid #2a3960; border-radius: 12px; }

.levels { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 760px; }
.lvl { width: 132px; padding: 12px 8px; border-radius: 12px; background: #1f2a44; border: 2px solid #35476f; color: #e8ecf5;
  font: inherit; cursor: pointer; text-align: center; }
.lvl b { display: block; font-size: 26px; color: #ffd84a; }
.lvl small { display: block; color: #8fa3c8; font-size: 12px; margin-top: 2px; }
.lvl:disabled { opacity: .35; cursor: default; }
.lvl:not(:disabled):hover { background: #2a3960; border-color: #ff7a4d; }
.owned { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 640px; min-height: 26px; }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 99px; background: #26365a; color: #cfe0ff; }

.cards { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.card { width: 190px; padding: 18px 14px; border-radius: 14px; background: #1f2a44; border: 2px solid #35476f; color: #e8ecf5;
  font: inherit; cursor: pointer; text-align: center; transition: transform .1s, border-color .15s; }
.card:hover { transform: translateY(-4px); border-color: #ffd84a; }
.card i { display: block; font-style: normal; font-size: 38px; margin-bottom: 6px; }
.card b { display: block; font-size: 17px; color: #ffd84a; margin-bottom: 6px; }
.card span { font-size: 13px; color: #a9b8d6; }

.help { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; max-width: 760px; }
.help > div { width: min(340px, 100%); background: rgba(19, 26, 44, .8); border: 1px solid #2a3960; border-radius: 12px; padding: 14px 18px; }
.help b { color: #ffd84a; }
.help p { margin-top: 8px; font-size: 14px; line-height: 1.7; color: #b9c6e0; }

.tbtn { position: fixed; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(255, 255, 255, .12); color: #fff; font-size: 24px; touch-action: none; }
.tbtn:active { background: rgba(255, 255, 255, .3); }
#btnJump { right: calc(22px + env(safe-area-inset-right)); bottom: calc(170px + env(safe-area-inset-bottom)); }
#btnSwap { right: calc(100px + env(safe-area-inset-right)); bottom: calc(190px + env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 20px; }
#btnRoll { right: calc(30px + env(safe-area-inset-right)); bottom: calc(246px + env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 20px; }
#btnPause { position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: 42px; height: 34px;
  border-radius: 8px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(0, 0, 0, .35); color: #fff; font-size: 13px; touch-action: none; }

@media (max-height: 420px) {
  .screen { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .btn { padding: 8px 18px; font-size: 15px; }
  .col { flex-direction: row; flex-wrap: wrap; justify-content: center; width: auto; }
  .card { width: 160px; padding: 10px; }
  .card i { font-size: 26px; }
  #btnJump { bottom: calc(140px + env(safe-area-inset-bottom)); }
  #btnSwap { bottom: calc(155px + env(safe-area-inset-bottom)); }
  #btnRoll { bottom: calc(212px + env(safe-area-inset-bottom)); }
}

.check { font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; padding: 0; accent-color: #d8452b; }
.invited { color: #ffd84a; font-size: 15px; font-weight: 600; }
.code { font-size: clamp(34px, 9vw, 60px); font-weight: 900; letter-spacing: .18em; color: #fff; padding: 6px 22px;
  background: #131a2c; border: 2px dashed #ff7a4d; border-radius: 14px; -webkit-user-select: text; user-select: text; }
input.link { width: min(520px, 100%); text-align: center; font-size: 14px; color: #b9c6e0; }
.panel .row { align-items: center; }
