:root {
  --accent: #49c6ff;
  --accent-rgb: 73, 198, 255;
  --cream: #fff2dc;
  --muted: #d9bfae;
  --ink: #140a16;
  --sun: #ff8a3d;
  --pink: #ff7aa8;
  --glass: rgba(24, 10, 28, .58);
  --line: rgba(255, 210, 180, .16);
}
body[data-side="sith"] { --accent: #ff3046; --accent-rgb: 255, 48, 70; }

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #140a16; color: var(--cream); font-family: Inter, system-ui, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 55%, transparent 55%, rgba(10, 4, 12, .6) 100%); }

.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.show { display: flex; }

/* ---------- logo ---------- */
.logo { font-family: "Zen Dots", Inter, sans-serif; font-weight: 400; line-height: .9; letter-spacing: .02em;
  font-size: clamp(54px, 9vw, 112px); display: flex; gap: .22em; flex-wrap: wrap; }
.logo .l1 { background: linear-gradient(180deg, #fff7e6 0%, #ffd08a 45%, #ff7a3c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 18px rgba(255, 120, 60, .45)); }
.logo .l2 { color: #fff; text-shadow: 0 0 6px #fff, 0 0 18px var(--accent), 0 0 42px var(--accent), 0 0 80px rgba(var(--accent-rgb), .6);
  transition: text-shadow .4s; }

/* ---------- gate ---------- */
#gate { align-items: center; justify-content: center; cursor: pointer; background: rgba(12, 5, 16, .35); }
.gate-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 18px; animation: rise 1.2s ease both; }
.gate-kanji { font-family: "Shippori Mincho B1", serif; font-size: clamp(22px, 3vw, 34px); letter-spacing: .5em; color: #ffd3b0; opacity: .85; padding-left: .5em; }
.gate-hint { font-size: 14px; letter-spacing: .35em; text-transform: uppercase; color: var(--muted); animation: pulse 1.8s ease-in-out infinite; }

/* ---------- menu ---------- */
#menu { flex-direction: column; overflow-y: auto; overflow-x: hidden;
  background: linear-gradient(90deg, rgba(14, 6, 18, .82) 0%, rgba(14, 6, 18, .45) 45%, rgba(14, 6, 18, .25) 100%); }
#menu.show > * { animation: rise .7s ease both; }
#menu.show .play-panel { animation-delay: .1s; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px clamp(16px, 4vw, 48px); }
.brand { display: flex; align-items: center; gap: 10px; font-family: "Zen Dots", sans-serif; font-size: 15px; letter-spacing: .06em; }
.brand img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; object-position: 50% 18%; border: 2px solid rgba(var(--accent-rgb), .7); box-shadow: 0 0 14px rgba(var(--accent-rgb), .5); }
.ticker { font-family: Inter, sans-serif; font-weight: 800; font-size: 12px; padding: 3px 8px; border-radius: 99px; background: rgba(255, 138, 61, .18); color: #ffc08a; border: 1px solid rgba(255, 138, 61, .35); }
.socials { display: flex; gap: 8px; }
.socials a { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); transition: .2s; }
.socials a:hover { border-color: rgba(var(--accent-rgb), .7); box-shadow: 0 0 16px rgba(var(--accent-rgb), .35); transform: translateY(-2px); }
.socials svg { width: 18px; height: 18px; fill: currentColor; }
.soon { opacity: .45; cursor: not-allowed; }

.menu-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px); gap: clamp(20px, 4vw, 64px);
  align-items: start; padding: clamp(8px, 3vh, 40px) clamp(16px, 4vw, 48px) 24px; max-width: 1320px; width: 100%; margin: 0 auto; }

.hero { position: relative; padding-top: 3vh; }
.kanji-side { position: absolute; left: -4px; top: 0; transform: translateX(-120%); writing-mode: vertical-rl;
  font-family: "Shippori Mincho B1", serif; font-size: 22px; letter-spacing: .4em; color: rgba(255, 190, 150, .45); }
.eyebrow { font-size: 13px; letter-spacing: .32em; text-transform: uppercase; color: #ffb38a; margin-bottom: 14px; }
.tagline { margin: 22px 0 28px; font-size: clamp(16px, 1.6vw, 19px); line-height: 1.6; color: var(--muted); max-width: 520px; }

.ca-box { display: flex; align-items: center; gap: 0; max-width: 560px; border-radius: 14px; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ca-label { padding: 14px 14px; font-weight: 800; font-size: 13px; letter-spacing: .1em; color: #1a0b0b; background: linear-gradient(135deg, #ffd08a, #ff7a3c); align-self: stretch; display: grid; place-items: center; }
#ca { flex: 1; min-width: 0; padding: 0 14px; font-family: "JetBrains Mono", monospace; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #ffe6cf; }
#copyCa { padding: 14px 18px; font-weight: 700; font-size: 13px; border-left: 1px solid var(--line); transition: .2s; }
#copyCa:hover { background: rgba(var(--accent-rgb), .15); color: #fff; }
#copyCa.done { color: #8dffb0; }

.cta-row { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 24px; border-radius: 12px; font-weight: 700; font-size: 15px; transition: .2s; }
.btn.solid { background: linear-gradient(135deg, #ffd08a, #ff7a3c 60%, #ff5a5a); color: #1d0b0b; box-shadow: 0 6px 24px rgba(255, 110, 60, .35); }
.btn.solid:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(255, 110, 60, .5); }
.btn.ghost { background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.btn.ghost:hover { border-color: rgba(var(--accent-rgb), .6); box-shadow: 0 0 18px rgba(var(--accent-rgb), .25); }

.play-panel { background: var(--glass); border: 1px solid var(--line); border-radius: 22px; padding: 22px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.play-panel h2, .card h2 { font-family: "Zen Dots", sans-serif; font-weight: 400; font-size: 18px; letter-spacing: .04em; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.play-panel h2 small, .card h2 small { font-family: "Shippori Mincho B1", serif; font-size: 15px; color: #ffb38a; }

.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0 14px; }
.side-card { position: relative; border-radius: 16px; overflow: hidden; aspect-ratio: 3 / 3.6; border: 2px solid transparent; transition: .25s; background: #000; }
.side-card img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; display: block; transition: transform .5s, filter .3s; filter: saturate(.75) brightness(.7); }
.side-card:hover img { transform: scale(1.05); filter: saturate(1) brightness(.9); }
.side-card .side-info { position: absolute; inset: auto 0 0 0; padding: 26px 12px 10px; text-align: left;
  background: linear-gradient(transparent, rgba(8, 3, 10, .92)); display: flex; flex-direction: column; }
.side-info b { font-family: "Zen Dots", sans-serif; font-weight: 400; font-size: 15px; }
.side-info span { font-size: 12px; color: var(--muted); }
.side-card.jedi.selected { border-color: #49c6ff; box-shadow: 0 0 26px rgba(73, 198, 255, .55), inset 0 0 20px rgba(73, 198, 255, .3); }
.side-card.sith.selected { border-color: #ff3046; box-shadow: 0 0 26px rgba(255, 48, 70, .55), inset 0 0 20px rgba(255, 48, 70, .3); }
.side-card.selected img { filter: none; }

.diff { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.diff button { padding: 9px 4px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--muted); transition: .2s; }
.diff button.on { background: rgba(var(--accent-rgb), .18); color: #fff; box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), .6); }

.play-btn { position: relative; width: 100%; margin: 16px 0 14px; padding: 18px; border-radius: 99px; display: flex; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(0, 0, 0, .2)); border: 2px solid rgba(var(--accent-rgb), .9);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), .7), 0 0 40px rgba(var(--accent-rgb), .35), inset 0 0 18px rgba(var(--accent-rgb), .45); transition: .25s; overflow: hidden; }
.play-btn::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, .35) 50%, transparent 70%); transform: translateX(-100%); animation: sheen 3s ease-in-out infinite; }
.play-btn span { font-family: "Zen Dots", sans-serif; font-size: 24px; letter-spacing: .2em; color: #fff; text-shadow: 0 0 12px var(--accent); }
.play-btn i { font-style: normal; font-family: "Shippori Mincho B1", serif; font-size: 20px; color: rgba(255, 255, 255, .75); }
.play-btn:hover { transform: scale(1.02); box-shadow: 0 0 20px rgba(var(--accent-rgb), .9), 0 0 70px rgba(var(--accent-rgb), .5), inset 0 0 24px rgba(var(--accent-rgb), .6); }

.keys { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); }
kbd { display: inline-block; min-width: 22px; padding: 2px 6px; margin-right: 3px; border-radius: 6px; text-align: center; font-family: "JetBrains Mono", monospace; font-size: 11px; color: #fff;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .18); border-bottom-width: 2px; }
.tip { margin-top: 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.tip b { color: #ffd08a; }

footer { padding: 14px clamp(16px, 4vw, 48px) 20px; font-size: 11px; color: rgba(217, 191, 174, .55); text-align: center; }

/* ---------- HUD ---------- */
#hud { position: fixed; z-index: 5; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: clamp(10px, 2vw, 24px);
  padding: max(14px, env(safe-area-inset-top)) clamp(14px, 4vw, 48px) 0; pointer-events: none; }
.bar { display: flex; flex-direction: column; gap: 6px; }
.bar.p2 { align-items: flex-end; }
.name { font-family: "Zen Dots", sans-serif; font-size: clamp(12px, 1.4vw, 16px); letter-spacing: .08em; text-shadow: 0 2px 8px rgba(0, 0, 0, .7); }
.hp { position: relative; width: 100%; height: clamp(14px, 2vh, 20px); border-radius: 4px; transform: skewX(-14deg); overflow: hidden;
  background: rgba(10, 4, 12, .65); border: 1px solid rgba(255, 230, 210, .35); box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }
.p2 .hp { transform: skewX(14deg); }
.hp i, .hp b { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; transition: width .08s; }
.p2 .hp i, .p2 .hp b { left: auto; right: 0; }
.hp b { background: #ffe0b0; transition: width .6s ease .25s; }
.hp i { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000)); box-shadow: 0 0 12px var(--c); }
.pips { display: flex; gap: 6px; }
.pips span { width: 12px; height: 12px; transform: rotate(45deg); border: 1px solid rgba(255, 230, 210, .6); background: rgba(0, 0, 0, .4); }
.pips span.won { background: #ffd08a; box-shadow: 0 0 10px #ff9a3c; }
.timer { width: clamp(54px, 6vw, 72px); height: clamp(54px, 6vw, 72px); border-radius: 50%; display: grid; place-items: center; position: relative;
  background: radial-gradient(circle, rgba(30, 10, 30, .85), rgba(10, 4, 12, .85)); border: 2px solid rgba(255, 190, 140, .5); box-shadow: 0 0 24px rgba(255, 120, 60, .35); }
.timer span { font-family: "Zen Dots", sans-serif; font-size: clamp(18px, 2.4vw, 26px); }
.timer small { position: absolute; bottom: -18px; font-family: "Shippori Mincho B1", serif; font-size: 12px; color: #ffb38a; }
#pauseBtn { position: fixed; top: max(96px, calc(env(safe-area-inset-top) + 84px)); left: 50%; transform: translateX(-50%); pointer-events: auto;
  width: 34px; height: 34px; border-radius: 10px; font-size: 11px; background: var(--glass); border: 1px solid var(--line); }

#banner { position: fixed; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; opacity: 0; }
#banner b { font-family: "Zen Dots", sans-serif; font-weight: 400; font-size: clamp(48px, 10vw, 128px); letter-spacing: .06em; color: #fff;
  text-shadow: 0 0 10px #fff, 0 0 30px var(--bc, #ff8a3d), 0 0 70px var(--bc, #ff8a3d); }
#banner small { font-family: "Shippori Mincho B1", serif; font-size: clamp(20px, 3vw, 34px); color: #ffd3b0; margin-top: 4px; letter-spacing: .3em; }
#banner.go { animation: bannerIn var(--d, 1.2s) ease both; }

/* ---------- modals ---------- */
.modal { align-items: center; justify-content: center; background: rgba(10, 4, 12, .55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 20; padding: 16px; }
.card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 10px; padding: 26px; border-radius: 22px; text-align: center;
  background: var(--glass); border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, .5); animation: rise .4s ease both; }
.card h2 { justify-content: center; font-size: 26px; margin-bottom: 6px; }
.res-kanji { font-family: "Shippori Mincho B1", serif; font-size: 64px; line-height: 1; color: #ffd08a; text-shadow: 0 0 30px rgba(255, 140, 60, .6); }
#result.lose .res-kanji { color: #c9b6c9; text-shadow: none; }
#resSub { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stats div { padding: 10px 4px; border-radius: 12px; background: rgba(0, 0, 0, .3); border: 1px solid var(--line); }
.stats b { display: block; font-family: "Zen Dots", sans-serif; font-size: 20px; font-weight: 400; }
.stats span { font-size: 11px; color: var(--muted); }

/* ---------- touch ---------- */
#touch { position: fixed; z-index: 7; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-bottom)); pointer-events: none; }
#touch .pad { display: flex; gap: 10px; pointer-events: auto; align-items: flex-end; }
#touch button { width: 62px; height: 62px; border-radius: 50%; font-size: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  background: rgba(20, 8, 24, .5); border: 1px solid rgba(255, 220, 190, .3); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); user-select: none; -webkit-user-select: none; touch-action: none; }
#touch .right button { font-family: "Shippori Mincho B1", serif; }
#touch button small { font-family: Inter, sans-serif; font-size: 9px; color: var(--muted); margin-top: 3px; }
#touch button.big { width: 78px; height: 78px; border-color: rgba(var(--accent-rgb), .8); box-shadow: 0 0 18px rgba(var(--accent-rgb), .4); }
#touch button.down { background: rgba(var(--accent-rgb), .3); }

#muteBtn { position: fixed; z-index: 30; right: 14px; bottom: 14px; width: 42px; height: 42px; border-radius: 12px; font-size: 18px; background: var(--glass); border: 1px solid var(--line); }
body.touch.playing #muteBtn { bottom: auto; top: 108px; right: 14px; }

/* ---------- 3D extras ---------- */
#crosshair { position: fixed; z-index: 4; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; pointer-events: none; }
#crosshair::before, #crosshair::after { content: ""; position: absolute; background: rgba(255, 240, 220, .75); box-shadow: 0 0 6px rgba(var(--accent-rgb), .8); }
#crosshair::before { left: 10px; top: 4px; width: 2px; height: 14px; }
#crosshair::after { top: 10px; left: 4px; width: 14px; height: 2px; }
#dmg { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 10, 20, .65) 100%); }
#pops { position: fixed; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font-family: "Zen Dots", sans-serif; white-space: nowrap; color: #fff;
  text-shadow: 0 2px 0 rgba(20, 6, 16, .9), 0 0 14px rgba(0, 0, 0, .6); animation: popUp 1s ease-out forwards; }
.pop.center { left: 50%; }
@keyframes popUp { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -160%) scale(.95); } }
#lock { position: fixed; inset: 0; z-index: 8; display: flex; align-items: center; justify-content: center; cursor: pointer; background: rgba(10, 4, 12, .35); }
#lock div { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px 34px; border-radius: 18px; background: var(--glass); border: 1px solid rgba(var(--accent-rgb), .6); box-shadow: 0 0 30px rgba(var(--accent-rgb), .3); }
#lock b { font-family: "Zen Dots", sans-serif; font-weight: 400; font-size: 22px; letter-spacing: .1em; }
#lock span { font-size: 13px; color: var(--muted); }
#loading { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: #140a16; transition: opacity .6s; }
#loading span { font-family: "Zen Dots", sans-serif; letter-spacing: .2em; font-size: 14px; color: #ffb38a; animation: pulse 1.4s infinite; }
#loading.done { opacity: 0; pointer-events: none; }
.stick { pointer-events: none; width: 120px; height: 120px; border-radius: 50%; border: 1px solid rgba(255, 220, 190, .3); background: rgba(20, 8, 24, .35); position: relative; opacity: .6; }
.stick i { position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px; border-radius: 50%; background: rgba(var(--accent-rgb), .35); border: 1px solid rgba(var(--accent-rgb), .7); }

/* Netlify free-tier injects a "Powered by Netlify" badge iframe; keep the game screen clean */
#nl-badge-frame { display: none !important; }

/* ---------- animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes sheen { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@keyframes bannerIn { 0% { opacity: 0; transform: scale(1.6); filter: blur(8px); } 15% { opacity: 1; transform: scale(1); filter: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.95); } }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .menu-main { grid-template-columns: 1fr; }
  .kanji-side { display: none; }
  .hero { padding-top: 0; }
  #menu { background: linear-gradient(180deg, rgba(14, 6, 18, .7), rgba(14, 6, 18, .5)); }
}
@media (max-width: 480px) {
  .topbar { padding: 14px 16px; }
  .brand b { display: none; }
  .socials a { width: 36px; height: 36px; }
  .play-panel { padding: 16px; }
  .sides { aspect-ratio: auto; }
  .side-card { aspect-ratio: 3 / 3.2; }
}
