/*
 * style.css — Geminate!: board, tiles, and advisor panel.
 *
 * The tile colour palette and board styling below are derived from 2048 by
 * Gabriele Cirulli (https://github.com/gabrielecirulli/2048):
 *
 *   Copyright (c) 2014 Gabriele Cirulli
 *   Permission is hereby granted, free of charge, to any person obtaining a
 *   copy of this software and associated documentation files (the "Software"),
 *   to deal in the Software without restriction, including without limitation
 *   the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *   and/or sell copies of the Software, and to permit persons to whom the
 *   Software is furnished to do so, subject to the following conditions:
 *   The above copyright notice and this permission notice shall be included in
 *   all copies or substantial portions of the Software.
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND. See
 *   THIRD-PARTY-NOTICES.md for the full text.
 *
 * This is the one file containing verbatim derived expression, so the notice
 * lives here directly — it must survive minification and bundling.
 */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #faf8ef;
  --text: #776e65;
  --board: #bbada0;
  --cell: rgba(238, 228, 218, 0.35);
  --btn: #8f7a66;
  --panel: #ffffff;
  --good: #2e9e5b;
  --bad: #d84a3f;
  --meh: #d89b3f;
  /* board geometry: 4 tiles of 21.25% + 5 gaps of 3% */
  --tile-size: 21.25%;
  --step: 24.25%;
  --gap: 3%;
}

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 980px; margin: 0 auto; padding: 18px 16px 40px; }

/* ------------------------------------------------------------- header --- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; }
h1 { font-size: 48px; line-height: 1.05; color: var(--text); letter-spacing: -1px; }
.subtitle { font-size: 14px; color: #a99e93; margin-top: 2px; }
.score-boxes { display: flex; gap: 8px; }
.score-box {
  position: relative;
  background: var(--board);
  color: #fff;
  border-radius: 6px;
  padding: 6px 18px;
  text-align: center;
  min-width: 88px;
}
.score-box .label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #eee4da; }
.score-box .value { display: block; font-size: 22px; font-weight: 700; }
.score-add {
  position: absolute; left: 0; right: 0; top: 8px;
  font-weight: 700; color: rgba(119, 110, 101, 0.9);
  opacity: 0; pointer-events: none;
}
.score-add.bump { animation: score-bump 0.7s ease-out; }
@keyframes score-bump {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-28px); }
}

/* ------------------------------------------------------------- layout --- */
.layout { display: flex; gap: 20px; align-items: flex-start; }
.board-col { flex: 0 1 460px; min-width: 0; }
.advisor { flex: 1 1 320px; min-width: 280px; }

/* -------------------------------------------------------------- board --- */
.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: var(--board);
  border-radius: 8px;
  touch-action: none;
  user-select: none;
}
.board.shake { animation: shake 0.18s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-5px); }
  66% { transform: translateX(5px); }
}

.grid-cell, .tile {
  position: absolute;
  width: var(--tile-size);
  height: var(--tile-size);
  left: calc(var(--gap) + var(--c) * var(--step));
  top: calc(var(--gap) + var(--r) * var(--step));
  border-radius: 5px;
}
.grid-cell { background: var(--cell); }

.tile-layer { position: absolute; inset: 0; }
.tile {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: clamp(20px, 6.5vw, 42px);
  background: #eee4da; color: #776e65;
  transition: left 0.12s ease, top 0.12s ease;
  z-index: 2;
}
.tile.dying { z-index: 1; }
.tile.tile-new { animation: appear 0.16s ease 0.1s backwards; }
.tile.tile-merged { animation: pop 0.18s ease 0.08s backwards; z-index: 3; }
@keyframes appear { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.tile-v2 { background: #eee4da; }
.tile-v4 { background: #ede0c8; }
.tile-v8 { background: #f2b179; color: #f9f6f2; }
.tile-v16 { background: #f59563; color: #f9f6f2; }
.tile-v32 { background: #f67c5f; color: #f9f6f2; }
.tile-v64 { background: #f65e3b; color: #f9f6f2; }
.tile-v128, .tile-v256, .tile-v512 { font-size: clamp(18px, 5.4vw, 36px); color: #f9f6f2; }
.tile-v128 { background: #edcf72; }
.tile-v256 { background: #edcc61; }
.tile-v512 { background: #edc850; }
.tile-v1024, .tile-v2048, .tile-vsuper { font-size: clamp(15px, 4.4vw, 30px); color: #f9f6f2; }
.tile-v1024 { background: #edc53f; }
.tile-v2048 { background: #edc22e; box-shadow: 0 0 24px 6px rgba(243, 215, 116, 0.6); }
.tile-vsuper { background: #3c3a32; }

.hint-arrow {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 120px; font-weight: 700; color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.35);
  opacity: 0; pointer-events: none; z-index: 5;
}
.hint-arrow.show { animation: hint-pulse 0.9s ease; }
@keyframes hint-pulse {
  0% { opacity: 0; transform: scale(0.6); }
  25% { opacity: 1; transform: scale(1.1); }
  60% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.overlay {
  position: absolute; inset: 0; z-index: 10;
  background: rgba(238, 228, 218, 0.82);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
}
.overlay-inner { padding: 0 18px; }
.overlay-inner h2 { font-size: 40px; margin-bottom: 8px; }
.overlay-inner p { max-width: 380px; margin: 0 auto 16px; line-height: 1.45; }
.overlay-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.overlay-note { margin-top: 12px; font-size: 12px; color: #8a7f74; }

.hidden { display: none !important; }

/* ------------------------------------------------------------ controls -- */
.controls { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
button, select {
  font: inherit;
  background: var(--btn); color: #f9f6f2;
  border: none; border-radius: 5px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { filter: brightness(1.08); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: #e2903c; }
button.active { background: #d84a3f; }
select { padding: 8px 6px; }
.hud { margin-top: 10px; font-size: 14px; }
.howto { margin-top: 6px; font-size: 13px; color: #a99e93; }

/* ------------------------------------------------------------- advisor -- */
.advisor {
  background: var(--panel);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: 0 2px 14px rgba(119, 110, 101, 0.14);
}
.advisor-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.advisor-head h2 { font-size: 22px; }
.advisor-opts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.advisor-opts select, .advisor-opts button { padding: 5px 8px; font-size: 13px; }

.coach-msg {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  background: #f6f2ea;
  border-left: 4px solid #cfc4b6;
  min-height: 42px;
}
.coach-good { background: #ecf7f0; border-left-color: var(--good); }
.coach-bad { background: #fdeeec; border-left-color: var(--bad); }
.coach-meh { background: #fdf6ea; border-left-color: var(--meh); }
.coach-msg a { color: #4a76c9; }

.advisor-sub { font-size: 13px; color: #8d8478; margin-bottom: 8px; }
.info { cursor: help; }

.move-cards { display: flex; flex-direction: column; gap: 8px; }
.move-cards.analyzing .mc-pct { opacity: 0.35; }
.move-card {
  display: flex; gap: 10px; align-items: center;
  border: 2px solid #eee7dc;
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color 0.15s, background 0.15s;
}
.move-card.best { border-color: var(--good); background: #f4fbf6; }
.move-card.illegal { opacity: 0.42; }
.move-card.hint-flash { animation: hint-card 0.9s ease; }
@keyframes hint-card {
  0%, 100% { background: inherit; }
  30% { background: #dff3e6; }
}
.mc-arrow { font-size: 26px; font-weight: 700; width: 34px; text-align: center; }
.mc-main { flex: 1; min-width: 0; }
.mc-top { display: flex; align-items: baseline; gap: 8px; }
.mc-name { font-weight: 600; font-size: 14px; }
.mc-tag { font-size: 10px; font-weight: 700; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 4px; }
.tag-best { background: var(--good); color: #fff; }
.tag-good { background: #d9efe1; color: #22794a; }
.tag-mid { background: #f0ead9; color: #94824e; }
.tag-risky { background: #fbe3cd; color: #b16a1f; }
.tag-bad { background: #f9d8d3; color: #b03a2e; }
.mc-pct { margin-left: auto; font-size: 18px; font-weight: 700; }
.mc-bar { height: 6px; background: #f0ebe2; border-radius: 3px; margin: 5px 0 4px; overflow: hidden; }
.mc-bar-fill { height: 100%; width: 0; background: linear-gradient(90deg, #e8b34c, #2e9e5b); border-radius: 3px; transition: width 0.25s ease; }
.mc-why { font-size: 12px; color: #93897c; }

/* "Feedback only" mode hides the numbers until after you move. */
.mode-feedback .move-cards, .mode-feedback .analysis-status { filter: blur(7px); pointer-events: none; }
.mode-off .move-cards, .mode-off .analysis-status, .mode-off .advisor-sub { display: none; }

.analysis-status { margin-top: 10px; font-size: 12px; color: #a49a8d; min-height: 16px; }
.acc-line { margin-top: 6px; font-size: 13px; font-weight: 600; color: #7d7468; }

/* -------------------------------------------------------------- modal --- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(60, 54, 46, 0.5);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: #fff;
  border-radius: 12px;
  max-width: 560px; width: 100%;
  max-height: 84vh;
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid #eee7dc;
}
.modal-head button { background: none; color: var(--text); font-size: 18px; padding: 4px 8px; }
.modal-body { padding: 6px 18px 18px; overflow-y: auto; }
.lesson { padding: 12px 0; border-bottom: 1px solid #f2ede4; }
.lesson:last-child { border-bottom: none; }
.lesson h3 { margin-bottom: 6px; font-size: 16px; }
.lesson p { font-size: 14px; line-height: 1.5; margin-bottom: 6px; }
.lesson .tip { background: #f6f2ea; border-radius: 6px; padding: 8px 10px; font-size: 13px; }

/* Third-party notices. Legal text, so it is de-emphasised but must stay
   legible — do not hide it or collapse it behind an interaction. */
.notices { border-top: 1px solid #e7e0d6; padding-top: 12px; margin-top: 4px; }
.notices .notice-head { font-size: 13px; font-weight: 700; margin-top: 12px; margin-bottom: 2px; }
.notices .notice-what { font-size: 13px; color: #8c8177; margin-bottom: 4px; }
.notices .notice-text { font-size: 11px; line-height: 1.45; color: #9a9086; }
.mini-grid {
  display: grid; grid-template-columns: repeat(4, 52px); gap: 4px;
  margin: 10px 0;
}
.mini-grid span {
  height: 40px; display: flex; align-items: center; justify-content: center;
  background: #eee4da; border-radius: 4px; font-weight: 700; font-size: 13px; color: #776e65;
}
.mini-grid .hot { background: #edc53f; color: #fff; }
.mini-grid .hot2 { background: #edc22e; color: #fff; box-shadow: 0 0 10px rgba(243, 215, 116, 0.8); }

/* -------------------------------------------------------------- credits -- */
/* Visible attribution — this is what discharges the MIT notice condition for
   a web deployment. Do not remove when redistributing. */
.credits {
  margin: 22px auto 4px; max-width: 900px; padding: 0 4px;
  font-size: 11.5px; line-height: 1.6; color: #a89c8f; text-align: center;
}
.credits a { color: #948779; text-decoration: underline; }
.credits a:hover { color: #776e65; }

/* ---------------------------------------------------------- responsive -- */
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .board-col { width: 100%; max-width: 460px; margin: 0 auto; }
  .advisor { width: 100%; }
  h1 { font-size: 36px; }
  .subtitle { font-size: 12.5px; }
}

/* Narrow phones: keep the header from eating the screen above the board. */
@media (max-width: 480px) {
  h1 { font-size: 28px; }
  .subtitle { font-size: 11.5px; }
  .score-box { padding: 5px 12px; min-width: 70px; }
}
