@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700;800;900&family=Rye&display=swap");

:root {
  --forest: #173f2b;
  --forest-dark: #0b251c;
  --moss: #6f923f;
  --moss-light: #a9bd66;
  --stone: #817d68;
  --stone-light: #b2a98a;
  --parchment: #f1e5bd;
  --ink: #292e20;
  --fire: #f04d25;
  --fire-light: #ffc33d;
  --water: #159bd4;
  --water-light: #75e2ff;
  --gold: #e3bd55;
  --line: rgba(237, 226, 185, .22);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  overflow-x: hidden;
  color: #f8f0d6;
  background:
    radial-gradient(circle at 50% 20%, rgba(176, 209, 108, .2), transparent 27%),
    linear-gradient(rgba(8, 31, 22, .35), rgba(5, 23, 17, .88)),
    repeating-linear-gradient(90deg, #133b29 0 55px, #103422 55px 110px);
  font-family: "Noto Sans SC", system-ui, sans-serif;
}
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  pointer-events: none;
}
body::before {
  inset: 0;
  opacity: .25;
  background:
    radial-gradient(ellipse at 5% 2%, #9cbd56 0 5%, transparent 6%),
    radial-gradient(ellipse at 95% 8%, #7da34a 0 7%, transparent 8%),
    radial-gradient(ellipse at 8% 92%, #557c37 0 9%, transparent 10%),
    radial-gradient(ellipse at 92% 88%, #527237 0 10%, transparent 11%);
}
body::after {
  left: 0;
  right: 0;
  bottom: 0;
  height: 28vh;
  background: linear-gradient(transparent, rgba(2, 18, 12, .8));
}
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.grain { position: fixed; inset: 0; z-index: 20; pointer-events: none; opacity: .09; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E"); }

.lobby { width: min(1120px, calc(100% - 36px)); min-height: 100vh; margin: auto; padding: 48px 0; display: grid; grid-template-columns: 1.08fr .92fr; align-items: center; gap: clamp(44px, 8vw, 110px); position: relative; }
.lobby::before { content: ""; position: absolute; left: -9vw; top: -40px; width: 290px; height: 360px; border-left: 18px solid rgba(59, 94, 47, .52); border-radius: 50%; transform: rotate(-24deg); box-shadow: 24px 12px 0 -15px rgba(104, 139, 57, .55), 45px 42px 0 -16px rgba(104, 139, 57, .4); }
.lobby-copy { position: relative; z-index: 1; }
.wordmark { display: flex; align-items: center; gap: 12px; color: #cdd5a1; font: 700 11px "Rye", serif; letter-spacing: .19em; text-shadow: 0 2px 2px #0a2419; }
.wordmark i { color: var(--gold); font-style: normal; }
.kicker { margin: 58px 0 10px; color: #d6c77e; font-size: 12px; font-weight: 800; letter-spacing: .22em; }
.lobby-copy h1 { margin: 0; font-family: "Rye", "Noto Sans SC", serif; font-size: clamp(65px, 7.8vw, 106px); line-height: .93; letter-spacing: -.055em; filter: drop-shadow(0 8px 2px rgba(4, 24, 16, .46)); }
.lobby-copy h1 span { color: #f1dfa5; -webkit-text-stroke: 1px #574f30; }
.lobby-copy h1 em { color: #f7eecf; font-style: normal; text-shadow: -4px 0 var(--fire), 4px 0 var(--water), 0 5px #4b4128; }
.intro { width: min(480px, 95%); margin: 27px 0 0; color: #d0d8b4; font-size: 14px; line-height: 1.85; text-shadow: 0 2px 2px #0b291d; }
.character-preview { height: 135px; margin-top: 25px; display: flex; align-items: center; }
.preview-orbit { width: 105px; height: 105px; display: grid; place-items: center; position: relative; border: 5px solid #5f6848; border-radius: 48% 52% 45% 55%; background: radial-gradient(circle, #4e7244, #264832 70%); box-shadow: inset 0 0 0 3px #929170, 0 9px 20px rgba(0,0,0,.35); }
.preview-orbit::after { content: ""; position: absolute; inset: -13px; border: 4px dotted rgba(170, 191, 100, .35); border-radius: 50%; }
.preview-line { width: 65px; height: 8px; background: linear-gradient(#9b9676, #575944); box-shadow: 0 4px #303d2d; }
.mini-hero { width: 48px; height: 62px; border: 3px solid rgba(53, 41, 27, .55); border-radius: 22px 22px 14px 14px; position: relative; }
.fire-mini { color: var(--fire); background: linear-gradient(150deg, #ffc13d, #e84823); box-shadow: 0 6px 20px rgba(240,77,37,.65); }
.water-mini { color: var(--water); background: linear-gradient(150deg, #8cecff, #168fc9); box-shadow: 0 6px 20px rgba(21,155,212,.65); }
.mini-hero i { position: absolute; left: 9px; top: 23px; width: 8px; height: 10px; border-radius: 50%; background: white; box-shadow: 20px 0 white; }
.mini-hero i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 3px; height: 5px; border-radius: 50%; background: #253126; box-shadow: 20px 0 #253126; }
.mini-hero b { position: absolute; left: 9px; bottom: -8px; width: 13px; height: 12px; border-radius: 0 0 8px 8px; background: currentColor; box-shadow: 21px 0 currentColor; }
.fire-mini::before { content: ""; position: absolute; left: 7px; top: -23px; border-left: 17px solid transparent; border-right: 14px solid transparent; border-bottom: 34px solid var(--fire-light); transform: rotate(-7deg); }
.water-mini::before { content: ""; position: absolute; left: 10px; top: -21px; width: 27px; height: 34px; background: var(--water-light); border-radius: 70% 30% 60% 40% / 70% 35% 65% 30%; transform: rotate(45deg); }

.room-card { position: relative; padding: clamp(28px, 4vw, 46px); border: 8px solid #696a51; border-radius: 11px; background: linear-gradient(145deg, rgba(236,225,187,.97), rgba(197,190,151,.97)); color: var(--ink); box-shadow: inset 0 0 0 3px #aaa487, 0 0 0 6px rgba(28,53,34,.65), 0 26px 60px rgba(0,0,0,.42); }
.room-card::before, .room-card::after { content: ""; position: absolute; width: 48px; height: 70px; top: -25px; background: radial-gradient(ellipse at 40% 30%, #8fa64f 0 26%, transparent 28%), radial-gradient(ellipse at 70% 65%, #607f3c 0 29%, transparent 31%); }
.room-card::before { left: -28px; transform: rotate(-22deg); }
.room-card::after { right: -30px; transform: scaleX(-1) rotate(-22deg); }
.connection-line { display: flex; align-items: center; gap: 8px; color: #666951; font-size: 12px; }
.connection-line i { width: 9px; height: 9px; border-radius: 50%; background: #d49d36; box-shadow: 0 0 0 3px rgba(90,83,51,.15); }
.connection-line i.online { background: #4f9b4c; }
.connection-line i.offline { background: #c94d3a; }
.step { margin: 38px 0 8px; color: #55743e; font: 700 11px "Rye", serif; letter-spacing: .13em; }
.room-card h2 { margin: 0; color: #2c3525; font-size: clamp(27px, 3vw, 36px); letter-spacing: -.04em; }
.room-tip { margin: 12px 0 27px; color: #65674f; font-size: 13px; line-height: 1.65; }
.primary-action { width: 100%; height: 60px; padding: 0 21px; display: flex; align-items: center; justify-content: space-between; border: 3px solid #714121; border-radius: 7px; background: linear-gradient(#d7853f, #a95528); color: #fff5d2; box-shadow: inset 0 2px #efa963, 0 5px #66351d; cursor: pointer; font-weight: 900; text-shadow: 0 2px #65331d; transition: transform .15s; }
.primary-action:hover:not(:disabled) { transform: translateY(-2px); filter: saturate(1.12); }
.primary-action:active:not(:disabled) { transform: translateY(3px); box-shadow: inset 0 2px #efa963, 0 2px #66351d; }
.primary-action b { font-size: 20px; }
button:disabled { cursor: not-allowed; opacity: .5; }
.divider { height: 56px; display: flex; align-items: center; gap: 12px; color: #77765c; font-size: 11px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 2px; background: rgba(70,74,51,.2); }
.join-form { display: grid; grid-template-columns: 1fr 84px; gap: 9px; }
.join-form input { min-width: 0; height: 54px; border: 3px solid #77745a; border-radius: 6px; outline: 0; padding: 0 15px; color: #313627; background: #f6edcf; box-shadow: inset 0 3px 8px rgba(72,67,44,.15); font-size: 17px; font-weight: 700; letter-spacing: .16em; }
.join-form input:focus { border-color: #628449; }
.join-form button, .waiting-overlay button, .win-overlay button, .header-actions button { border: 3px solid #4c653c; border-radius: 6px; background: linear-gradient(#7e9e55, #53783f); color: #fff7d8; box-shadow: inset 0 2px rgba(255,255,255,.2), 0 3px #314b2f; cursor: pointer; font-weight: 800; }
.lobby-error { min-height: 20px; margin: 11px 0 0; color: #b9382d; font-size: 12px; }
.room-rules { margin-top: 20px; padding-top: 17px; border-top: 2px dashed rgba(73,77,51,.25); display: flex; justify-content: space-between; color: #74755a; font-size: 10px; }
.room-rules span::before { content: "◆"; margin-right: 5px; color: #71904c; font-size: 7px; }

.game-screen { min-height: 100vh; padding: 10px clamp(8px, 1.8vw, 24px) 18px; }
.game-screen, .game-screen * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.game-screen img, .game-screen canvas, .game-screen button { -webkit-user-drag: none; }
.game-header { max-width: 1500px; height: 58px; margin: auto; padding: 0 15px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border: 4px solid #64644d; border-radius: 8px; background: linear-gradient(#9c9676, #696b53); box-shadow: inset 0 2px #c5bd96, 0 5px 0 #263b2c; }
.compact-brand { display: flex; align-items: center; }
.compact-brand span { width: 32px; height: 38px; display: grid; place-items: center; font-size: 11px; font-weight: 900; border: 2px solid rgba(57,44,27,.4); }
.brand-fire { background: linear-gradient(#ffb832, #e94d25); border-radius: 65% 35% 50% 50%; }
.brand-water { margin-left: -5px; background: linear-gradient(#76e4ff, #188fc9); border-radius: 55% 45% 65% 35%; }
.compact-brand b { margin-left: 10px; color: #f4e9be; font-family: "Rye", serif; font-size: 13px; text-shadow: 0 2px #3f4434; }
.room-code-box { display: flex; align-items: center; gap: 10px; }
.room-code-box small { color: #e0d5ad; font-size: 10px; }
.room-code-box button { padding: 6px 11px; border: 2px solid #4d513d; border-radius: 5px; background: #4d513e; cursor: pointer; }
.room-code-box b { color: #fff0b8; font-family: "Rye", serif; font-size: 16px; letter-spacing: .16em; }
.room-code-box span { margin-left: 8px; color: #cfd99c; font-size: 10px; }
.header-actions { justify-self: end; display: flex; align-items: center; gap: 12px; }
.network-status { color: #dff6b8; font-size: 11px; }
.network-status::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #87c95e; }
.network-status.offline { color: #ffd0c4; }
.header-actions button { padding: 6px 13px; font-size: 11px; }
.leave-button { border-color: #7b493d!important; background: linear-gradient(#a96550, #783e35)!important; }
.game-body { max-width: 1500px; margin: 10px auto 0; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; }
.mission-panel { padding: 23px 19px; border: 5px solid #666650; border-radius: 8px; background: linear-gradient(rgba(232,221,181,.96), rgba(179,175,137,.96)); color: #323729; box-shadow: inset 0 0 0 2px #a9a384, 0 6px 0 #24392a; }
.panel-label { margin: 0; color: #5b7940; font: 700 9px "Rye", serif; letter-spacing: .14em; }
.mission-panel h2 { margin: 8px 0; font-size: 24px; }
.mission-panel > p:not(.panel-label) { margin: 0 0 22px; color: #656950; font-size: 11px; line-height: 1.7; }
.mission-row { min-height: 61px; display: flex; align-items: center; gap: 11px; border-top: 2px dashed rgba(66,72,47,.2); }
.mission-row i { width: 34px; height: 34px; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 50%; font-style: normal; background: rgba(255,255,255,.25); }
.fire-row i { color: var(--fire); }.water-row i { color: var(--water); }.gate-row i { color: #92752e; }
.mission-row span { flex: 1; display: flex; flex-direction: column; }.mission-row b { font-size: 12px; }.mission-row small { margin-top: 2px; color: #6f7259; font-size: 10px; }
.element-rule { margin-top: 18px; padding: 13px; border: 2px solid rgba(77,105,54,.35); border-radius: 6px; background: rgba(103,137,64,.12); }
.element-rule b, .element-rule span { display: block; }.element-rule b { margin-bottom: 4px; color: #4f7737; font-size: 11px; }.element-rule span { color: #6b6e55; font-size: 10px; line-height: 1.55; }
.stage { min-width: 0; }
.player-strip { min-height: 50px; padding: 0 6px 7px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.player-pill { display: flex; align-items: center; gap: 8px; }.water-pill { justify-content: flex-end; text-align: right; }
.player-pill > i { width: 10px; height: 10px; border: 2px solid #eee1b8; border-radius: 50%; background: #686d58; }.player-pill.online > i { background: currentColor; box-shadow: 0 0 9px currentColor; }
.fire-pill { color: var(--fire-light); }.water-pill { color: var(--water-light); }.player-pill span { display: flex; flex-direction: column; }.player-pill small { color: #9fa888; font-size: 9px; }.player-pill b { color: #f4e9c0; font-size: 12px; }.player-pill em { color: #a9b090; font-size: 10px; font-style: normal; }
.your-role { padding: 6px 13px; border: 2px solid #7b7d61; border-radius: 20px; color: #e9dfba; background: rgba(32,59,42,.7); font-size: 10px; }.your-role.fire { color: var(--fire-light); }.your-role.water { color: var(--water-light); }
.canvas-wrap { position: relative; overflow: hidden; aspect-ratio: 16/9; border: 7px solid #62634d; border-radius: 10px; background: #173e31; box-shadow: inset 0 0 0 3px #989477, 0 8px 0 #213629, 0 20px 45px rgba(0,0,0,.35); }
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.waiting-overlay, .win-overlay { position: absolute; inset: 0; display: none; place-items: center; align-content: center; text-align: center; color: #f8edca; background: radial-gradient(circle, rgba(38,83,57,.78), rgba(9,35,25,.94)); backdrop-filter: blur(4px); }
.waiting-overlay.visible, .win-overlay.visible { display: grid; }
.waiting-symbol { width: 78px; height: 48px; position: relative; margin-bottom: 15px; }.waiting-symbol i { position: absolute; width: 39px; height: 48px; border: 4px solid; border-radius: 50%; animation: orbit 1.8s ease-in-out infinite; }.waiting-symbol i:first-child { left: 3px; border-color: var(--fire); }.waiting-symbol i:last-child { right: 3px; border-color: var(--water); animation-delay: -.9s; }
@keyframes orbit { 50% { transform: translateX(13px) scale(.82); opacity: .5; } }
.waiting-overlay p, .win-overlay > p { margin: 0; color: #e5cf76; font: 700 10px "Rye", serif; letter-spacing: .12em; }.waiting-overlay h2 { margin: 10px 0 6px; font-size: clamp(21px,3vw,34px); text-shadow: 0 3px #17301f; }.waiting-overlay > span { color: #d2dab4; font-size: 12px; }.waiting-overlay button, .win-overlay button { margin-top: 18px; padding: 9px 18px; font-size: 11px; }
.win-overlay h2 { margin: 11px 0 20px; font: 400 clamp(28px,4vw,50px)/1.18 "Rye", serif; text-shadow: 0 3px #193521; }.win-overlay > div { display: flex; gap: 8px; }.win-overlay > div span { min-width: 120px; padding: 11px 16px; border: 2px solid rgba(238,224,179,.3); border-radius: 6px; background: rgba(21,56,38,.55); display: flex; flex-direction: column; }.win-overlay small { color: #b9c59d; font-size: 9px; }.win-overlay b { margin-top: 3px; color: #fff0b5; font: 700 20px "Rye", serif; }
.toast { position: absolute; left: 50%; bottom: 18px; z-index: 4; max-width: 82%; padding: 9px 15px; transform: translate(-50%,15px); border: 2px solid #77755a; border-radius: 20px; background: rgba(238,225,184,.94); color: #343829; opacity: 0; pointer-events: none; transition: .2s; font-size: 11px; font-weight: 700; }.toast.visible { opacity: 1; transform: translate(-50%,0); }
.touch-controls { display: none; justify-content: space-between; padding: 15px 2px max(10px,env(safe-area-inset-bottom)); user-select: none; }
.touch-controls button { border: 4px solid #686951; border-radius: 50%; background: linear-gradient(#aaa486,#706f58); color: #fff1c2; box-shadow: inset 0 3px rgba(255,255,255,.22), 0 5px #2e4734; touch-action: none; -webkit-tap-highlight-color: transparent; text-shadow: 0 2px #4b4b39; }
.touch-controls button.active { transform: translateY(4px) scale(.96); box-shadow: inset 0 3px rgba(255,255,255,.18), 0 1px #2e4734; filter: brightness(1.15); }
.move-controls { display: flex; gap: 13px; }.move-controls button { width: 78px; height: 72px; font-size: 29px; }.jump-control { width: 96px; height: 72px; display: flex; align-items: center; justify-content: center; gap: 5px; border-color: #8b7437!important; background: linear-gradient(#d0a943,#947026)!important; }.jump-control span { font-size: 25px; }.jump-control b { font-size: 11px; }
.desktop-hint { margin: 12px 0 0; text-align: center; color: #aeb895; font-size: 10px; }kbd { min-width: 23px; margin: 0 2px; padding: 3px 6px; border: 2px solid #6e7058; border-radius: 4px; background: #8e8b6c; color: #fff0bd; font: inherit; }

@media (max-width: 980px) { .lobby { grid-template-columns: 1fr 420px; gap: 30px; }.lobby-copy h1 { font-size: 72px; }.game-body { display: block; }.mission-panel { display: none; } }
@media (hover:none), (pointer:coarse) { .touch-controls { display: flex; }.desktop-hint { display: none; } }
@media (max-width:720px) {
  body { background-color: var(--forest-dark); }
  .lobby { width: min(100% - 24px,500px); min-height: auto; grid-template-columns: 1fr; gap: 25px; padding: 26px 0 38px; }.lobby::before { display:none; }.wordmark { justify-content:center; }.kicker { margin-top:30px; text-align:center; }.lobby-copy h1 { font-size: clamp(56px,18vw,80px); text-align:center; }.intro { width:100%; margin-top:21px; text-align:center; font-size:13px; }.character-preview { height:100px; margin-top:20px; justify-content:center; }.preview-orbit { width:82px; height:82px; }.preview-line { width:44px; }.mini-hero { transform:scale(.75); }.room-card { padding:26px 20px; border-width:6px; }.step { margin-top:26px; }.room-card h2 { font-size:27px; }
  .game-screen { padding:6px 6px 0; }.game-header { height:46px; grid-template-columns:1fr auto; padding:0 9px; border-width:3px; }.compact-brand b,.network-status,.room-code-box small,.room-code-box span { display:none; }.room-code-box { justify-self:end; }.header-actions { display:flex; gap:5px; }.restart-button { display:none; }.leave-button { display:block; padding:5px 8px!important; font-size:10px!important; }.game-body { margin-top:5px; }.player-strip { min-height:40px; padding-bottom:4px; grid-template-columns:1fr 1fr; }.your-role,.player-pill em,.player-pill small { display:none; }.canvas-wrap { width:calc(100vw - 12px); border-width:4px; border-radius:7px; }.waiting-overlay h2 { font-size:20px; }.waiting-overlay > span { font-size:10px; }.toast { bottom:8px; white-space:nowrap; }.touch-controls { padding-left:8px; padding-right:8px; }.move-controls button { width:72px; height:68px; }.jump-control { width:90px; height:68px; }
}
@media (max-width:720px) and (orientation:portrait) {
  .game-screen { min-height:100dvh; padding-bottom:max(8px, env(safe-area-inset-bottom)); }
  .canvas-wrap { height:auto; min-height:0; aspect-ratio:16/9; }
  .touch-controls { min-height:112px; padding:16px 10px max(12px, env(safe-area-inset-bottom)); align-items:center; }
  .move-controls { gap:16px; }
  .move-controls button { width:82px; height:78px; }
  .jump-control { width:104px; height:78px; }
}
@media (max-height:540px) and (orientation:landscape) {
  .game-screen { padding:2px; }.game-header { display:none; }.game-body { margin:0; }.player-strip { position:fixed; z-index:5; top:3px; left:50%; width:min(500px,55vw); min-height:30px; transform:translateX(-50%); padding:3px 12px; border-radius:16px; background:rgba(18,55,38,.7); pointer-events:none; }.canvas-wrap { width:min(calc(100vh * 1.777),100vw); height:min(100vh,56.25vw); margin:auto; border-width:3px; }.touch-controls { position:fixed; z-index:8; inset:0; padding:0 16px max(8px,env(safe-area-inset-bottom)); align-items:flex-end; pointer-events:none; }.touch-controls button { pointer-events:auto; opacity:.9; }.move-controls button { width:78px; height:70px; }.jump-control { width:96px; height:70px; }.toast { bottom:78px; }
}
