/* ===== alap ===== */
:root {
  --bg0: #0b0f1a;
  --bg1: #131a2e;
  --card: rgba(255, 255, 255, .06);
  --card2: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .12);
  --fg: #eef2ff;
  --dim: #9aa6c4;
  --p0: #4fd1ff;
  --p1: #ff7a9c;
  --ok: #46e3a0;
  --warn: #ffcc57;
  --bad: #ff6b6b;
  --r: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(1200px 700px at 15% -10%, #24365e 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 0%, #3a2350 0%, transparent 55%),
    linear-gradient(170deg, var(--bg1), var(--bg0) 60%);
  background-attachment: fixed;
  color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
}

#app {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 12px calc(var(--safe-b) + 10px);
  max-width: 760px; margin: 0 auto;
}

.screen { display: none; flex: 1; flex-direction: column; animation: fade .25s ease; }
.screen.on { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== altalanos elemek ===== */
h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -.5px; }
h2 { font-size: 19px; margin: 0 0 10px; }
p.sub { color: var(--dim); margin: 0 0 22px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

button, .btn {
  appearance: none; border: 0; cursor: pointer;
  font: inherit; font-weight: 650;
  color: #0b0f1a;
  background: linear-gradient(135deg, #7ee0ff, #6aa8ff);
  border-radius: 14px;
  padding: 14px 18px;
  min-height: 50px;
  transition: transform .12s ease, filter .12s ease, opacity .12s;
}
button:active, .btn:active { transform: scale(.97); filter: brightness(1.08); }
button:disabled { opacity: .38; cursor: default; transform: none; }
button.ghost {
  background: var(--card2); color: var(--fg);
  border: 1px solid var(--line);
}
button.sm { min-height: 40px; padding: 9px 14px; font-size: 14px; border-radius: 11px; }
button.wide { width: 100%; }
button.danger { background: linear-gradient(135deg, #ff8f8f, #ff5f7a); }

input, textarea {
  width: 100%; font: inherit; color: var(--fg);
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line);
  border-radius: 13px; padding: 14px;
  outline: none; user-select: text;
}
input:focus { border-color: var(--p0); }
input::placeholder { color: #6c7899; }

.row { display: flex; gap: 10px; }
.row.tight { gap: 6px; }
.grow { flex: 1; }
.center { text-align: center; }
.dim { color: var(--dim); }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }

/* ===== home ===== */
.brand { text-align: center; margin: 26px 0 20px; }
.brand .logo { font-size: 54px; line-height: 1; }
.brand h1 { background: linear-gradient(100deg, #8fe6ff, #b39bff 60%, #ff9ec4); -webkit-background-clip: text; background-clip: text; color: transparent; }

.codebox input {
  text-align: center; letter-spacing: 12px;
  font-size: 30px; font-weight: 800; text-transform: uppercase;
  padding: 16px 10px 16px 22px;
}

/* ===== lobby / jatekvalaszto ===== */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.topbar .code { font-weight: 800; letter-spacing: 3px; font-size: 17px; }
.topbar .who { font-size: 12px; color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

.cat { font-size: 12px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--dim); margin: 18px 0 8px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gtile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 14px 12px;
  text-align: left; color: var(--fg);
  display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
}
.gtile .ic { font-size: 28px; }
.gtile .nm { font-weight: 700; font-size: 15px; }
.gtile .ds { font-size: 11.5px; color: var(--dim); line-height: 1.35; }
.gtile:active { background: var(--card2); }

.waiting {
  text-align: center; padding: 26px 14px;
  border: 1px dashed var(--line); border-radius: var(--r);
  color: var(--dim);
}
.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .5 } 50% { opacity: 1 } }

/* ===== jatek keret ===== */
#gameWrap { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.scorebar {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 12px;
}
.pchip { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; }
.pchip .bul { width: 12px; height: 12px; border-radius: 50%; }
.pchip.me .nm { text-decoration: underline; text-underline-offset: 3px; }
.pchip.turn { animation: glow 1.4s ease-in-out infinite; }
@keyframes glow { 0%,100% { filter: none } 50% { filter: drop-shadow(0 0 6px currentColor) } }
.c0 { color: var(--p0); } .bg0 { background: var(--p0); }
.c1 { color: var(--p1); } .bg1 { background: var(--p1); }

.status {
  text-align: center; font-size: 14px; min-height: 20px;
  color: var(--dim);
}
.status b { color: var(--fg); }

#board { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; }

.banner {
  position: fixed; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(6, 9, 18, .78); backdrop-filter: blur(6px);
  z-index: 50; padding: 24px;
}
.banner.on { display: flex; animation: fade .2s; }
.banner .in {
  background: linear-gradient(160deg, #1b2440, #141a2e);
  border: 1px solid var(--line); border-radius: 22px;
  padding: 26px 22px; text-align: center; max-width: 340px; width: 100%;
}
.banner .big { font-size: 42px; }
.banner h2 { font-size: 24px; margin: 8px 0 4px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 18px);
  background: #2a2140; border: 1px solid var(--line);
  color: #ffd9e2; padding: 11px 16px; border-radius: 12px;
  font-size: 14px; z-index: 90; max-width: 90%;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* ===== amoba / connect4 / dama tablak ===== */
.boardgrid { display: grid; gap: 3px; background: rgba(0,0,0,.25); padding: 6px; border-radius: 14px; }
.cell {
  background: rgba(255,255,255,.05); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; aspect-ratio: 1;
}
.cell.win { background: rgba(70,227,160,.3); box-shadow: 0 0 0 2px var(--ok) inset; }
.cell.last { box-shadow: 0 0 0 2px var(--warn) inset; }
.cell.x { color: var(--p0); } .cell.o { color: var(--p1); }

.c4 { display: grid; gap: 5px; background: rgba(30,45,90,.55); padding: 8px; border-radius: 16px; }
.c4 .slot { aspect-ratio: 1; border-radius: 50%; background: rgba(0,0,0,.35); position: relative; }
.c4 .slot.p0 { background: radial-gradient(circle at 32% 30%, #9be9ff, #24a7d6); }
.c4 .slot.p1 { background: radial-gradient(circle at 32% 30%, #ffb6c9, #e0496f); }
.c4 .slot.win { box-shadow: 0 0 0 3px var(--ok), 0 0 14px var(--ok); }
.c4cols { display: grid; gap: 5px; padding: 0 8px; margin-bottom: 4px; }
.c4cols button { min-height: 34px; padding: 0; font-size: 15px; border-radius: 9px; }

.dboard { display: grid; grid-template-columns: repeat(8, 1fr); width: 100%; max-width: 380px; border-radius: 12px; overflow: hidden; border: 2px solid rgba(255,255,255,.15); }
.dsq { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.dsq.dark { background: #4b3a56; } .dsq.light { background: #d9cfe0; }
.dsq.sel { box-shadow: 0 0 0 3px var(--warn) inset; }
.dsq.tgt::after { content: ''; width: 26%; height: 26%; border-radius: 50%; background: rgba(70,227,160,.85); position: absolute; }
.dsq.from { box-shadow: 0 0 0 3px rgba(255,255,255,.35) inset; }
.pieceD { width: 74%; height: 74%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 15px; box-shadow: 0 2px 5px rgba(0,0,0,.5); }
.pieceD.p0 { background: radial-gradient(circle at 33% 28%, #eaf7ff, #7fb6d8); color: #123; }
.pieceD.p1 { background: radial-gradient(circle at 33% 28%, #6a5170, #2d2136); color: #ffd9ea; }

/* ===== kartyak ===== */
.card-f {
  width: 62px; height: 88px; border-radius: 9px;
  background: linear-gradient(160deg, #fff, #e8ecf6);
  color: #14161f; position: relative; flex: 0 0 auto;
  box-shadow: 0 3px 8px rgba(0,0,0,.45);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 5px 6px; font-weight: 800;
}
.card-f.red { color: #d8214a; }
.card-f .mid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.card-f .tr { align-self: flex-end; transform: rotate(180deg); }
.card-f.back { background: repeating-linear-gradient(45deg, #38508f 0 6px, #2b3f74 6px 12px); box-shadow: 0 3px 8px rgba(0,0,0,.45), 0 0 0 2px rgba(255,255,255,.12) inset; }
.card-f.dis { opacity: .42; }
.card-f.sel { transform: translateY(-10px); box-shadow: 0 8px 16px rgba(0,0,0,.55), 0 0 0 2px var(--warn); }
.card-f.small { width: 46px; height: 66px; font-size: 12px; }
.card-f.small .mid { font-size: 19px; }

.hand { display: flex; gap: 6px; overflow-x: auto; padding: 12px 4px 8px; scrollbar-width: none; }
.hand::-webkit-scrollbar { display: none; }
.hand .card-f { transition: transform .15s; }

.uno-c {
  width: 62px; height: 92px; border-radius: 10px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 24px; color: #fff;
  border: 3px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.5);
  text-shadow: 0 2px 3px rgba(0,0,0,.45);
  position: relative; overflow: hidden;
}
.uno-c .lbl { font-size: 13px; line-height: 1.05; text-align: center; padding: 0 3px; }
.uno-c.R { background: linear-gradient(150deg, #ff6b6b, #d61f3a); }
.uno-c.Y { background: linear-gradient(150deg, #ffd95e, #e0a800); }
.uno-c.G { background: linear-gradient(150deg, #63e08a, #17a24a); }
.uno-c.B { background: linear-gradient(150deg, #6fb2ff, #1f5fd0); }
.uno-c.W { background: conic-gradient(#d61f3a 0 25%, #e0a800 0 50%, #17a24a 0 75%, #1f5fd0 0); }
.uno-c.dis { opacity: .4; }
.uno-c.big { width: 78px; height: 114px; font-size: 30px; }

.pilebox { display: flex; align-items: center; justify-content: center; gap: 22px; padding: 8px 0; }
.deckstack { position: relative; }
.deckstack .n { position: absolute; bottom: -18px; width: 100%; text-align: center; font-size: 11px; color: var(--dim); }

.colorpick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.colorpick button { min-height: 56px; border-radius: 14px; color: #fff; font-size: 13px; }
.colorpick .R { background: linear-gradient(150deg, #ff6b6b, #d61f3a); }
.colorpick .Y { background: linear-gradient(150deg, #ffd95e, #e0a800); color: #3a2c00; }
.colorpick .G { background: linear-gradient(150deg, #63e08a, #17a24a); }
.colorpick .B { background: linear-gradient(150deg, #6fb2ff, #1f5fd0); }

/* ===== memoria ===== */
.memgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; max-width: 340px; }
.memc { aspect-ratio: .78; border-radius: 12px; position: relative; perspective: 600px; }
.memc .inner { position: absolute; inset: 0; transition: transform .35s; transform-style: preserve-3d; }
.memc.up .inner { transform: rotateY(180deg); }
.memc .f, .memc .b {
  position: absolute; inset: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  backface-visibility: hidden; font-size: 30px;
}
.memc .b { background: repeating-linear-gradient(45deg, #3c5698 0 7px, #2c3f74 7px 14px); }
.memc .f { background: #f2f5ff; transform: rotateY(180deg); }
.memc.f0 .f { background: #cdeeff; } .memc.f1 .f { background: #ffd7e3; }

/* ===== reflex ===== */
.tappad {
  flex: 1; width: 100%; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 900; text-align: center; gap: 8px;
  min-height: 240px; transition: background .08s;
}
.tappad.wait { background: linear-gradient(160deg, #2c3350, #1b2136); color: var(--dim); font-size: 20px; }
.tappad.armed { background: linear-gradient(160deg, #b32c4a, #7a1730); color: #ffd9e2; }
.tappad.go { background: linear-gradient(160deg, #2ee08c, #0f9c5c); color: #04231a; }
.tappad.res { background: linear-gradient(160deg, #2a3a63, #1a2340); font-size: 20px; }

/* ===== rajzolas ===== */
.drawwrap { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
#ink { width: 100%; flex: 1; background: #101728; border-radius: 16px; border: 1px solid var(--line); touch-action: none; display: block; min-height: 200px; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); }
.swatch.on { border-color: #fff; transform: scale(1.14); }
.guesslog { max-height: 92px; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.guesslog .g { padding: 4px 8px; background: var(--card); border-radius: 8px; }
.guesslog .g.good { background: rgba(70,227,160,.22); color: #b6ffdf; }
.wordmask { font-size: 22px; letter-spacing: 6px; font-weight: 800; text-align: center; }

/* ===== kviz ===== */
.qbox { font-size: 19px; font-weight: 700; text-align: center; padding: 18px 12px; }
.answers { display: grid; gap: 9px; }
.answers button { text-align: left; background: var(--card2); color: var(--fg); border: 1px solid var(--line); }
.answers button.good { background: linear-gradient(135deg, #46e3a0, #1fa876); color: #052; border-color: transparent; }
.answers button.bad { background: linear-gradient(135deg, #ff8f8f, #e04a4a); color: #3a0000; border-color: transparent; }
.answers button.mine { box-shadow: 0 0 0 2px var(--warn); }
.timerbar { height: 7px; background: rgba(255,255,255,.12); border-radius: 4px; overflow: hidden; }
.timerbar i { display: block; height: 100%; background: linear-gradient(90deg, #7ee0ff, #ff9ec4); }

/* ===== forgatas keres ===== */
.rotate {
  display: none; text-align: center; padding: 30px 16px; color: var(--dim);
}
.rotate .ic { font-size: 46px; display: block; animation: rot 2.4s ease-in-out infinite; }
@keyframes rot { 0%,100% { transform: rotate(0) } 50% { transform: rotate(90deg) } }

body.needLandscape.portraitNow .rotate { display: block; }
body.needLandscape.portraitNow #board > *:not(.rotate) { display: none !important; }

/* ===== fekvo mod ===== */
@media (orientation: landscape) and (max-height: 520px) {
  #app { max-width: 100%; padding-top: calc(var(--safe-t) + 4px); }
  .topbar { padding: 5px 10px; margin-bottom: 6px; }
  h1 { font-size: 22px; }
  .brand { margin: 8px 0; }
  .brand .logo { font-size: 32px; }
  .grid { grid-template-columns: repeat(4, 1fr); }
  .gtile .ds { display: none; }
  .scorebar { padding: 5px 10px; }
  .card-f { width: 52px; height: 74px; }
  .uno-c { width: 52px; height: 78px; font-size: 20px; }
}
