/* =====================================================================
   Mahjong: a scholar's studio in warm daylight. Wooden desk, paper
   light, ivory tiles with lacquer-red accents; the layout itself is
   positioned by game.js, the 3D comes from bevel borders and layered
   shadows.
   ===================================================================== */

:root {
  --desk: #8a5a33;
  --desk-dk: #6e4425;
  --paperlight: #f6e8cf;
  --ivory: #f8f2e2;
  --ivory-dk: #d9cdb0;
  --lacquer: #a8352a;
  --inkblue: #2c4a8a;
  --ink: #3a2a1a;
  --gold: #c9a24b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Lora", Georgia, serif;
  color: var(--ink);
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 240, 205, 0.5), transparent 55%),
    radial-gradient(ellipse at 50% 120%, rgba(40, 20, 8, 0.4), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='w'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.008 0.06' numOctaves='3' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.28 0 0 0 0 0.14 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23w)'/%3E%3C/svg%3E"),
    var(--desk);
}

.nav-back-games {
  position: fixed; top: 14px; left: 16px; z-index: 50;
  font: 700 14px/1 "Lora", serif;
  color: var(--paperlight); text-decoration: none;
  background: rgba(60, 36, 18, 0.85);
  border: 1.5px solid var(--gold); border-radius: 6px;
  padding: 7px 13px;
}
.nav-back-games:hover { color: #fff; border-color: #e8cf96; }

/* ---- HUD -------------------------------------------------------------- */
#desk { height: 100%; display: flex; flex-direction: column; }
.hudline {
  display: flex; gap: 18px; align-items: center; justify-content: center;
  padding: 12px 90px 4px;
  font-size: 15px; color: var(--paperlight);
  text-shadow: 0 1px 2px rgba(40, 20, 8, 0.6);
  flex-wrap: wrap;
}
.hudline[hidden] { display: none; }
#hud-time { font-size: 20px; font-weight: 700; min-width: 64px; }
#hud-pairs { color: #e8cf96; }
.hud-btns { display: flex; gap: 8px; }
.hud-btns button {
  font: 700 13px/1 "Lora", serif; cursor: pointer;
  color: var(--paperlight); background: rgba(60, 36, 18, 0.8);
  border: 1.5px solid rgba(201, 162, 75, 0.6); border-radius: 6px;
  padding: 6px 11px;
}
.hud-btns button:hover { border-color: var(--gold); }
.hud-btns kbd {
  font-family: inherit; font-size: 10.5px; color: #e8cf96;
  background: rgba(246, 232, 207, 0.14); border: 1px solid rgba(201, 162, 75, 0.7);
}
/* a dead board's ways out (New deal, Daily: give up), shown by game.js */
.hud-stuck[hidden], .hud-stuck button[hidden] { display: none; }
.hud-stuck button { border-color: var(--gold); }

/* ---- the tiles ---------------------------------------------------------- */
#board { position: relative; flex: 1; margin: 6px auto 14px; }

button.tile {
  position: absolute;
  border: 0; padding: 0; cursor: default;
  background-color: var(--ivory);
  border-radius: 9% / 7%;
  box-shadow:
    inset 0 0 0 1px rgba(120, 100, 60, 0.35),
    -3px 4px 0 -1px var(--ivory-dk),               /* the tile's side */
    -4px 6px 0 -1px #b8a488,
    -6px 9px 10px rgba(40, 20, 8, 0.45);           /* drop to the desk */
  background-size: 100% 100%;
  background-repeat: no-repeat;
  -webkit-tap-highlight-color: transparent;
}
button.tile.free { cursor: pointer; }
button.tile.free:hover { filter: brightness(1.06); }
button.tile.sel {
  outline: 3px solid var(--gold);
  outline-offset: -1px;
  filter: brightness(1.1);
  box-shadow:
    inset 0 0 0 1px rgba(120, 100, 60, 0.35),
    -3px 4px 0 -1px var(--ivory-dk),
    -4px 6px 0 -1px #b8a488,
    -6px 9px 14px rgba(201, 162, 75, 0.65);
}
button.tile.hintg { animation: hintg 0.8s ease 2; }
@keyframes hintg {
  50% { filter: brightness(1.25) drop-shadow(0 0 10px rgba(201, 162, 75, 0.9)); }
}
button.tile.shake { animation: shake 0.28s ease; }
@keyframes shake { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
button.tile:focus { outline: none; }
button.tile.free:focus-visible { outline: 3px dashed var(--inkblue); outline-offset: 2px; }

body:not(.fxon) button.tile { transition: none !important; animation: none !important; }
/* With Visual FX off (no tile animations, above) a hint holds the glow at its
   peak and a blocked tile gets a red edge, until game.js clears the class
   (1.65s / 450ms) */
body:not(.fxon) button.tile.hintg { filter: brightness(1.25) drop-shadow(0 0 10px rgba(201, 162, 75, 0.9)); outline: 3px solid var(--gold); outline-offset: -1px; }
body:not(.fxon) button.tile.shake { outline: 3px solid var(--lacquer); outline-offset: -1px; }

/* a plum-blossom branch in the corner, painted in CSS */
.blossom { position: fixed; right: -30px; bottom: -20px; width: 220px; height: 190px; pointer-events: none; opacity: 0.85; z-index: 1;
  background:
    radial-gradient(circle 7px at 60px 60px, #e8a0b4 6px, transparent 7px),
    radial-gradient(circle 6px at 90px 34px, #f0b4c4 5px, transparent 6px),
    radial-gradient(circle 6px at 130px 52px, #e8a0b4 5px, transparent 6px),
    radial-gradient(circle 5px at 110px 84px, #f0b4c4 4px, transparent 5px),
    radial-gradient(circle 6px at 160px 90px, #e8a0b4 5px, transparent 6px),
    radial-gradient(circle 5px at 76px 108px, #f0b4c4 4px, transparent 5px),
    linear-gradient(115deg, transparent 47%, #4a2c16 48%, #4a2c16 52%, transparent 53%);
}

/* ---- panels --------------------------------------------------------------- */
.panel {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 26px 16px; overflow-y: auto;
  background: rgba(40, 22, 10, 0.55);
}
.panel[hidden] { display: none; }
.card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, #fbf3e0, var(--paperlight));
  border: 1px solid #c9b58a; border-radius: 12px;
  box-shadow: 0 16px 50px rgba(30, 16, 6, 0.55), inset 0 0 0 3px rgba(201, 162, 75, 0.25);
  padding: 24px 24px 20px;
}
.card h1, .card h2 { font-weight: 700; color: var(--lacquer); }
.card h1 { font-size: 32px; }
.card h2 { font-size: 24px; }
.card .tag { color: #7a6648; font-style: italic; margin: 3px 0 12px; }
.card .how { font-size: 15px; line-height: 1.55; margin-bottom: 14px; }
.card .how b { color: var(--lacquer); }

kbd {
  font-family: "Lora", serif; font-size: 11.5px;
  background: var(--ink); color: var(--paperlight);
  border-radius: 4px; padding: 1px 6px;
}

.pick .seg { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.seg button {
  font-family: inherit; font-size: 16px; text-align: left; cursor: pointer;
  color: var(--ink); background: rgba(255, 255, 255, 0.55);
  border: 1.5px solid #c9b58a; border-radius: 9px; padding: 9px 13px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.seg button small { font-size: 13px; color: #7a6648; }
.seg button.on { border-color: var(--lacquer); box-shadow: inset 0 0 0 1.5px var(--lacquer); background: #fff; }
.seg button.on b { color: var(--lacquer); }

.playbtn {
  font-family: inherit; font-size: 19px; font-weight: 700;
  width: 100%; cursor: pointer;
  color: var(--paperlight); background: linear-gradient(170deg, #c04a3c, var(--lacquer) 60%, #8a2a20);
  border: 0; border-radius: 10px; padding: 12px;
  box-shadow: 0 4px 0 #6e2018, 0 8px 18px rgba(60, 20, 10, 0.35);
}
.playbtn:hover { filter: brightness(1.07); }
.playbtn:active { transform: translateY(2px); box-shadow: 0 2px 0 #6e2018; }
.playbtn kbd { background: rgba(246, 232, 207, 0.25); }
.bests { margin-top: 12px; font-size: 13.5px; color: #7a6648; min-height: 17px; text-align: center; }

.card .big { font-size: 38px; font-weight: 700; color: var(--lacquer); margin: 6px 0 2px; }
.card .big small { font-size: 15px; color: #7a6648; }
.card .stats { font-size: 14.5px; color: #7a6648; margin: 4px 0 16px; white-space: pre-line; line-height: 1.6; }
.card .row { display: flex; gap: 10px; flex-wrap: wrap; }
.card .row button {
  font-family: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
  color: var(--ink); background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid #c9b58a; border-radius: 9px; padding: 9px 18px;
}
.card .row button:first-child {
  color: var(--paperlight); background: linear-gradient(170deg, #c04a3c, var(--lacquer));
  border-color: #8a2a20;
}
.card .row button:active { transform: translateY(1px); }

@media (max-width: 640px) {
  .hudline { padding: 52px 8px 2px; gap: 10px; font-size: 13px; }
  #hud-time { font-size: 17px; }
  .hud-btns button { padding: 5px 8px; font-size: 12px; }
  .hud-btns kbd { display: none; }
  .card h1 { font-size: 27px; }
  .blossom { display: none; }
}
