/* app.css — green felt, ivory tiles, one-thumb layout (PLAN.md §6.2).
   Phase 1: functional layout; Phase 8 polishes tile faces to SVG. */

:root {
  --felt: #1b4332;
  --felt-light: #2d6a4f;
  --ivory: #f6f1e7;
  --ivory-edge: #d9d0bd;
  --ink: #1d1d1f;
  --red: #c1121f;
  --blue: #1d4ed8;
  --green: #2f8f4e;
  --gold: #f2cc60;
  --warn: #b91c1c;
  --tile-w: 34px;
  --tile-h: 46px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--felt);
  color: var(--ivory);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  font-size: 15px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

section, header, nav { padding: 2px 6px; }

.sub { font-size: 10px; opacity: 0.75; display: block; line-height: 1.1; }

/* header */
#header { display: flex; align-items: center; justify-content: space-between; height: 36px; background: rgba(0,0,0,.25); }
#header .h-item { font-size: 13px; }
#header button { background: none; border: 1px solid rgba(255,255,255,.3); color: var(--ivory); border-radius: 6px; padding: 2px 8px; font-size: 12px; }

/* opponents */
#opponents { display: flex; flex-direction: column; gap: 2px; }
.opp {
  display: flex; align-items: center; gap: 6px; height: 26px;
  background: rgba(0,0,0,.18); border-radius: 8px; padding: 0 6px; font-size: 12px;
  border: 1px solid transparent;
}
.opp.turn { border-color: var(--gold); }
.opp .name { min-width: 52px; font-weight: 600; }
.opp .wind { color: var(--gold); }
.opp .badges { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.badge { background: rgba(255,255,255,.12); border-radius: 4px; padding: 0 4px; white-space: nowrap; }
.badge.facedown { background: rgba(0,0,0,.4); }

/* pool */
#pool {
  height: 118px; overflow-y: auto; background: rgba(0,0,0,.12);
  border-radius: 8px; margin: 2px 6px; padding: 4px;
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px;
}

/* tiles */
.tile {
  width: var(--tile-w); height: var(--tile-h);
  background: linear-gradient(#fff, var(--ivory) 60%, var(--ivory-edge));
  color: var(--ink); border: 1px solid #b8ad96; border-radius: 5px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 15px; line-height: 1; font-weight: 700; position: relative;
  padding: 0; font-family: inherit;
}
.tile .num { font-size: 11px; font-weight: 500; opacity: .8; }
.tile.man { color: #7f1d1d; }
.tile.pin { color: #1e3a8a; }
.tile.sou { color: #14532d; }
.tile.wind { color: #1d1d1f; }
.tile.dragon-31 { color: var(--red); }
.tile.dragon-32 { color: var(--green); }
.tile.dragon-33 { color: #9ca3af; }
.tile.flower-red { color: var(--red); font-size: 13px; }
.tile.flower-blue { color: var(--blue); font-size: 13px; }
.tile.animal { color: #78350f; font-size: 11px; }
.tile.claimed { opacity: .35; outline: none; }
.tile.selected { outline: 3px solid var(--gold); }
.tile.last-added { outline: 2px solid var(--gold); }
.tile.disabled { opacity: .25; }
.tile .count { position: absolute; right: 1px; bottom: 1px; font-size: 9px; font-weight: 500; color: #6b7280; }
.tile .by-tag { position: absolute; left: 1px; top: 1px; font-size: 8px; color: #6b7280; font-weight: 500; }

/* my row */
#myRow { min-height: 104px; }
#myRow .hand-tiles { display: flex; flex-wrap: wrap; gap: 3px; min-height: 48px; }
#myRow .melds { display: flex; gap: 8px; font-size: 11px; margin-top: 2px; flex-wrap: wrap; align-items: center; }
#myRow .meld { display: flex; gap: 1px; }
#myRow .meld .tile, .mini .tile { width: 22px; height: 30px; font-size: 11px; border-radius: 3px; }
.bonus-chip { background: rgba(255,255,255,.14); border-radius: 4px; padding: 1px 5px; font-size: 11px; }
.row-label { font-size: 11px; opacity: .7; margin-right: 4px; }

/* advisor + score strips (populated in later phases) */
#advisor { height: 42px; background: rgba(0,0,0,.18); border-radius: 8px; margin: 2px 6px; font-size: 12px; display: flex; align-items: center; gap: 8px; padding: 0 8px; overflow-x: auto; white-space: nowrap; }
#scoreStrip { height: 50px; background: rgba(0,0,0,.18); border-radius: 8px; margin: 2px 6px; font-size: 12px; display: flex; align-items: center; gap: 6px; padding: 0 8px; overflow-x: auto; }
.pattern-chip { background: rgba(242,204,96,.2); border: 1px solid rgba(242,204,96,.5); border-radius: 10px; padding: 1px 8px; white-space: nowrap; }
.pattern-chip.off { opacity: .4; text-decoration: line-through; }

/* advisor strip contents + sheet (Phase 6) */
.adv-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 100%;
  background: none; border: none; color: var(--ivory); font: inherit; font-size: 12px;
  padding: 0; text-align: left; white-space: nowrap;
}
.adv-lead { font-weight: 700; color: var(--gold); }
.adv-dead { color: #ff8a80; font-weight: 700; }
.adv-note { font-size: 12px; opacity: .85; }
.adv-accepts { display: flex; flex-wrap: wrap; gap: 4px; }
.adv-accept { background: rgba(255,255,255,.12); border-radius: 4px; padding: 2px 6px; font-size: 12px; }
.adv-accept.dead { background: rgba(193,18,31,.45); color: #ffd7d7; text-decoration: line-through; }
.adv-scroll { overflow-x: auto; }
.adv-table { border-collapse: collapse; width: 100%; font-size: 12px; }
.adv-table th, .adv-table td { padding: 3px 6px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.12); white-space: nowrap; }
.adv-table th { font-weight: 500; opacity: .7; }
.tier { border-radius: 4px; padding: 1px 5px; font-size: 11px; }
.tier-bao { background: var(--red); color: #fff; font-weight: 700; }
.tier-suspect { background: rgba(242,204,96,.35); color: var(--gold); }
.tier-safer { background: rgba(47,143,78,.4); }
.tier-unknown { background: rgba(255,255,255,.1); opacity: .8; }

/* settings panel + 对规则 summary (Phase 7) */
.set-group { margin-top: 8px; border-top: 1px solid rgba(255,255,255,.15); padding-top: 6px; font-weight: 600; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; }
.set-row .set-label { font-size: 13px; flex: 1; }
.set-ctl { display: flex; align-items: center; gap: 6px; }
.sheet .set-ctl button { width: 44px; height: 36px; flex: none; font-size: 16px; }
.sheet .set-ctl button.set-toggle { width: auto; min-width: 96px; padding: 0 10px; font-size: 12px; }
.set-val { min-width: 64px; text-align: center; font-size: 13px; }

/* action row */
#actions { display: flex; gap: 5px; height: 50px; align-items: center; }
#actions button {
  flex: 1; height: 42px; border-radius: 9px; border: none; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.14); color: var(--ivory); line-height: 1.15;
}
#actions button.primary { background: var(--gold); color: #422006; }
#actions button:disabled { opacity: .35; }

/* palette — persistent bottom keyboard, fixed grid, never reflows */
#palette { background: rgba(0,0,0,.3); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
#palette .p-row { display: grid; grid-template-columns: repeat(9, 1fr); gap: 3px; margin-bottom: 3px; }
#palette .p-row.honours { grid-template-columns: repeat(7, 1fr); }
#palette .p-row.bonus { grid-template-columns: repeat(12, 1fr); }
#palette .p-row .tile { width: 100%; height: 40px; }
#palette .mode-row { display: flex; gap: 4px; margin-bottom: 4px; }
#palette .mode-row button {
  flex: 1; height: 30px; border-radius: 7px; border: none; font-size: 12px;
  background: rgba(255,255,255,.12); color: var(--ivory);
}
#palette .mode-row button.active { background: var(--gold); color: #422006; font-weight: 700; }

/* claim bar */
.claim-bar {
  display: flex; gap: 5px; padding: 4px 6px; background: rgba(0,0,0,.5);
}
.claim-bar button { flex: 1; height: 40px; border-radius: 8px; border: none; font-size: 13px; font-weight: 600; background: var(--ivory); color: var(--ink); }
.claim-bar button.cancel { background: rgba(255,255,255,.2); color: var(--ivory); }

/* sheet (更多 / chooser) */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #123227; border-radius: 14px 14px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 30px rgba(0,0,0,.5);
  display: flex; flex-direction: column; gap: 6px; max-height: 70dvh; overflow-y: auto;
}
.sheet button { height: 44px; border-radius: 9px; border: none; font-size: 14px; background: rgba(255,255,255,.12); color: var(--ivory); }
.sheet button.danger { background: rgba(185,28,28,.5); }
.sheet .sheet-title { font-size: 13px; opacity: .8; text-align: center; }
.sheet .chooser { display: flex; gap: 6px; }
.sheet .chooser button { flex: 1; }

/* banner + toast */
.banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  background: var(--warn); color: #fff; padding: 10px; font-size: 14px; text-align: center;
}
.banner button { margin: 6px 4px 0; padding: 6px 14px; border-radius: 8px; border: none; font-size: 13px; }
.toast {
  position: fixed; bottom: 300px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(0,0,0,.85); color: #fff; border-radius: 10px; padding: 8px 16px;
  font-size: 13px; max-width: 86vw; text-align: center; pointer-events: none;
}
[hidden] { display: none !important; }
