:root{
  --bg:#f4f7ff;
  --bg2:#ffffff;
  --text:#0b1020;
  --muted:rgba(11,16,32,0.68);
  --card:rgba(255,255,255,0.92);
  --border:rgba(30,45,90,0.14);
  --shadow:0 18px 55px rgba(20,35,90,.12);
  --accent:#2f6bff;
  --accent2:#0fb37a;
  --warning:#ff4d4d;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Liberation Sans", sans-serif;
  color:var(--text);
  background:
    radial-gradient(1200px 700px at 20% 10%, #e9eeff 0%, transparent 60%),
    radial-gradient(900px 600px at 90% 20%, #e8fff5 0%, transparent 55%),
    linear-gradient(180deg, var(--bg), var(--bg2));
}

a{color:inherit; text-decoration:none}
.hidden{display:none !important}
.muted{color:var(--muted)}

.container{
  max-width: 980px;
  margin: 0 auto;
  padding: 22px 16px 28px;
}

.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.header{
  display:flex;
  gap:14px;
  align-items:center;
  margin-bottom: 14px;
}
.logo{
  width:76px; height:76px;
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(30,45,90,0.12);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  box-shadow: 0 14px 40px rgba(20,35,90,.10);
}
.logo img{width:100%; height:100%; object-fit:contain}

h1{margin:0; font-size: 34px; letter-spacing:-0.02em}
h2{margin:0 0 10px; font-size:22px}
p{margin: 8px 0; line-height:1.5}

.btn{
  border: 1px solid rgba(30,45,90,0.16);
  background: rgba(255,255,255,0.92);
  padding: 10px 14px;
  border-radius: 14px;
  cursor:pointer;
  font-weight: 850;
  transition: transform .05s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover{box-shadow:0 14px 30px rgba(20,35,90,.12)}
.btn:active{transform: translateY(1px)}
.btn.primary{
  border-color: rgba(47,107,255,.35);
  background: rgba(47,107,255,.14);
}
.btn.danger{
  border-color: rgba(255,77,77,.40);
  background: rgba(255,77,77,.12);
}
.row{display:flex; gap:10px; flex-wrap:wrap; align-items:center}

.game-list{display:flex; flex-direction:column; gap:12px; margin-top: 14px}
.game-item{
  display:flex;
  gap:14px;
  align-items:flex-start;
  justify-content:space-between;
  width:100%;
  padding: 14px;
  border-radius: 18px;
  border:1px solid rgba(30,45,90,0.12);
  background: rgba(255,255,255,0.86);
  box-shadow: 0 12px 36px rgba(20,35,90,.08);
}
.game-info{flex:1; padding-top:2px}
.game-name{font-weight: 950; font-size: 18px; margin-bottom: 2px}
.game-actions{display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:flex-end}

.topbar{
  position: sticky;
  top:0;
  z-index:10;
  background: rgba(245,247,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(30,45,90,0.10);
}
.topbar-inner{
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 14px;
  display:flex;
  gap:10px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}

.kpi{display:flex; gap:12px; flex-wrap:wrap; align-items:center}
.kpi .item{font-weight:900}
.kpi .item span{color:var(--muted); font-weight:800}

.center{
  min-height: calc(100vh - 64px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 14px;
}
.board-wrap{display:flex; justify-content:center; align-items:center}
canvas{
  max-width: 94vmin;
  max-height: 80vh;
  width: min(92vmin, 980px);
  height:auto;
  display:block;
}

.message{
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border:1px solid rgba(30,45,90,0.14);
  background: rgba(255,255,255,0.90);
}

.modal{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,0.45);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:9999;
  padding: 14px;
}
.modal-box{
  background: white;
  color: var(--text);
  border-radius: 18px;
  padding: 22px 24px;
  box-shadow: 0 22px 80px rgba(0,0,0,.25);
  max-width: 520px;
  width: 100%;
  text-align:center;
}
.modal-box h2{margin-top:0}

.grid2{display:grid; grid-template-columns: 1fr 1fr; gap:14px}
@media (max-width: 720px){
  .grid2{grid-template-columns:1fr}
  h1{font-size:28px}
  .game-actions{justify-content:flex-start}
}

/* Word memory */
.words-col, .recall-col{
  padding: 12px 14px;
  border-radius: 18px;
  border:1px solid rgba(30,45,90,0.12);
  background: rgba(255,255,255,0.88);
  box-shadow: 0 10px 30px rgba(20,35,90,.06);
}
.words-col ul{list-style:none; margin:0; padding:0}
.words-col li{padding:6px 0; border-bottom:1px dashed rgba(30,45,90,0.10)}
.words-col li:last-child{border-bottom:0}
.words-col .num{font-weight: 950; margin-right: 8px}

.recall-row{
  display:grid;
  grid-template-columns: 44px 1fr;
  gap:10px;
  align-items:center;
  padding: 6px 0;
  border-bottom:1px dashed rgba(30,45,90,0.10)
}
.recall-row:last-child{border-bottom:0}
.recall-row .num{font-weight:950; text-align:right; color: rgba(11,16,32,0.80)}
.recall-row input{
  width:100%;
  padding:10px 12px;
  border-radius: 14px;
  border:1px solid rgba(30,45,90,0.14);
  background: rgba(255,255,255,0.96);
  font-size: 15px;
}
.recall-row input:focus{
  outline:2px solid rgba(47,107,255,.30);
  border-color: rgba(47,107,255,.55)
}
.countdown{
  position:fixed;
  inset:0;
  background: rgba(245,247,255,0.92);
  backdrop-filter: blur(8px);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 96px;
  font-weight: 950;
  z-index:9998;
}