/* style.css — Cleaned */ 
:root {
  --cell: 14px;
  --cols: 40;
  --rows: 26;
  --radius: 6px;
  --bg: #f6f7f9;
  --panel: #fff;
  --ink: #0f172a;
  --border: #e5e7eb;
  --shadow: 0 2px 10px rgba(0,0,0,.08);
  --board-bg: #ffffff;
  --pulse: 59,130,246;
  --pulse-dur: 1.25s;
  --pulse-strong: .38;
  --pulse-weak: .18;
}

@media (max-width:600px) {
  :root { --cell: 12px; --cols: 26; --rows: 36; --radius: 5px; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Arial;
}

/* Topbar */
.topbar {
  padding: 10px 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar .actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Scoreboard */
.score {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 12px;
  background: linear-gradient(180deg, #ffffff, #f7f7f7);
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(0,0,0,.06), 0 0 0 2px rgba(var(--pulse), .2) inset;
  font-weight: 700;
  color:#111;
  user-select:none;
}
.score-floating {
  position:absolute;
  top:8px;
  left:50%;
  transform:translateX(-50%);
  z-index:5;
  pointer-events:none;
}

/* Game shell */
.shell {
  max-width: min(100vw, calc(var(--cell)*(var(--cols)+4)));
  margin: 10px auto;
  padding: 10px;
  position: relative;
}

/* Board */
.board {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  width: 100%;
  max-width: 90vmin;
  aspect-ratio: var(--cols) / var(--rows);
  background: var(--board-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  line-height: 0;
  font-size: 0;
  position: relative;
}

/* Tiles */
.tile {
  background: linear-gradient(145deg, #fff, #d9d9d9);
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  display: grid !important;
  position: relative;
}
.divider {
  position: absolute;
  background: #111;
  border-radius: 2px;
}

/* Player Hand */
.hand {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--panel);
  padding: 8px;
  border-top: 2px solid var(--border);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.15);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  z-index: 200;
}
.hand .tile {
  flex: 0 0 auto;
  cursor: pointer;
  outline: 2px solid transparent;
}
.hand .tile.playable { outline-color: #22c55e; }

/* AI hand */
.ai-hand {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -35%);
  display: flex;
  gap: 8px;
  pointer-events: none;
  z-index: 6;
}
.ai-hand .tile {
  width: calc(3 * var(--cell));
  height: calc(6 * var(--cell));
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 2px 6px rgba(0,0,0,.10);
}

/* Overlay */
.overlay {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.85);
  padding: 20px 30px;
  border-radius: 10px;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 90%;
}
.overlay button {
  margin-top: 20px;
  padding: 10px 20px;
  font-size: 1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: #22c55e;
  color: #fff;
}

/* Buttons */
.btn {
  -webkit-tap-highlight-color: transparent;
  appearance: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  padding: 10px 16px;
  transition: transform .08s ease, box-shadow .2s ease, background .2s ease, opacity .2s ease;
  outline: none;
}
.btn-pass, .btn-diff, .btn-quick {
  color:#fff;
  background: linear-gradient(180deg, rgba(var(--pulse), .85), rgba(var(--pulse), 1));
  box-shadow: 0 6px 16px rgba(var(--pulse), .25);
}
.btn-pass:hover, .btn-diff:hover, .btn-quick:hover { box-shadow: 0 8px 18px rgba(var(--pulse), .35); }
.btn-pass:active, .btn-diff:active, .btn-quick:active { transform: translateY(1px) scale(.99); }

#passBtn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

/* Popover menu */
.menu { position: relative; }
.menu-pop {
  position:absolute;
  top:100%;
  left:0;
  margin-top:6px;
  background: var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  box-shadow: var(--shadow);
  padding:6px;
  min-width: 200px;
  z-index: 300;
}
.menu-pop[hidden]{ display:none; }
.menu-item{
  display:block;
  width:100%;
  text-align:left;
  padding:10px 12px;
  background:none;
  border:none;
  border-radius:8px;
  cursor:pointer;
  font: inherit;
}
.menu-item:hover{ background: rgba(var(--pulse), .08); }
.menu-item[aria-checked="true"]{ background: rgba(var(--pulse), .12); font-weight: 700; }

/* Center the Pass button above the hand */
.controls {
  margin-top: 10px;
  text-align: center;
}

.fab-pass {
  position: static;   /* remove fixed positioning */
  margin: 0 auto;     /* center horizontally */
  display: inline-block;
}



/* === Custom Fixes === */
/* Make topbar buttons smaller */
.btn-diff, .btn-quick {
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 6px;
}

/* Floating Pass button above the hand */
.fab-pass {
  position: fixed;
  bottom: 90px; /* stays above the player's hand */
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  z-index: 300;
}

/* Highlight playable ends */
.tile.endhi {
  box-shadow: 0 0 0 3px rgba(34,197,94,0.9) inset,
              0 0 12px rgba(34,197,94,0.7);
  cursor: pointer;
  animation: pulse-endhi 1s infinite alternate;
}

@keyframes pulse-endhi {
  from { box-shadow: 0 0 0 3px rgba(34,197,94,0.9) inset,
                    0 0 12px rgba(34,197,94,0.7); }
  to   { box-shadow: 0 0 0 4px rgba(34,197,94,0.6) inset,
                    0 0 20px rgba(34,197,94,0.4); }
}

/* Flash effect on the tile just played */
.tile.just-played {
  animation: flash-played 0.8s ease-out;
}

@keyframes flash-played {
  0%   { box-shadow: 0 0 0 4px rgba(59,130,246,0.9),
                     0 0 20px rgba(59,130,246,0.7); }
  100% { box-shadow: none; }
}
