:root {
  --bg: #121213;
  --panel: #1b1b1d;
  --panel-2: #222326;
  --text: #f8f8f8;
  --muted: #a0a4ab;
  --border: #3a3a3c;
  --tile: #121213;
  --tile-border: #565758;
  --green: #6aaa64;
  --yellow: #c9b458;
  --grey: #3a3a3c;
  --button: #818384;
  --button-text: #ffffff;
  --shadow: rgba(0,0,0,0.28);
  --row-gap: 6px;
  --tile-size: min(13.5vw, 64px);
  --tile-gap: 6px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; min-height: 100vh; }
.app { width: fit-content; max-width: 100%; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: 320px auto; gap: 24px; align-items: start; }
.panel, .board-wrap { background: var(--panel); border: 1px solid #242528; border-radius: 18px; box-shadow: 0 12px 30px var(--shadow); }
.panel { padding: 20px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 16px; }
.panel-top, .panel-bottom { display: flex; flex-direction: column; gap: 18px; }
.title-bar { display: flex; align-items: center; justify-content: center; position: relative; }
h1 { margin: 0; font-size: 2.15rem; letter-spacing: 0.08em; font-weight: 800; }
.tag { color: var(--muted); line-height: 1.45; font-size: 0.97rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--panel-2); border-radius: 14px; padding: 12px; border: 1px solid #2a2b2f; }
.stat-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.stat-value { font-size: 1.35rem; font-weight: 800; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.icon-btn { width: 28px; height: 28px; padding: 0; border: 0; border-radius: 0; display: inline-grid; place-items: center; background: transparent; box-shadow: none; color: var(--muted); font-size: 1rem; line-height: 1; }
.icon-btn:hover, .icon-btn:active { transform: none; background: transparent; }
.icon-btn:hover { color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; display: block; fill: currentColor; }
button { border: 0; border-radius: 999px; padding: 11px 15px; font-size: 0.95rem; font-weight: 700; cursor: pointer; background: var(--button); color: var(--button-text); transition: transform 120ms ease, opacity 120ms ease, background 120ms ease; }
button:hover { transform: translateY(-1px); } button:active { transform: translateY(1px); }
.legend { display: grid; gap: 8px; font-size: 0.94rem; color: var(--muted); }
.legend-row { display: flex; gap: 10px; align-items: center; }
.legend-tile { width: 20px; height: 20px; border-radius: 4px; border: 2px solid rgba(255,255,255,0.08); flex: 0 0 auto; }
.board-wrap { padding: 20px; width: fit-content; max-width: 100%; position: relative; }
.board-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; padding-right: 48px; }
.message { color: var(--muted); min-height: 1.4em; font-size: 0.95rem; }
#soundBtn { position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 3; }
.rows { display: grid; gap: var(--row-gap); justify-content: start; }
.row { background: #17181a; border: 1px solid #26272b; border-radius: 16px; padding: 12px; display: inline-grid; grid-template-columns: auto; align-items: center; gap: 12px; width: fit-content; max-width: 100%; }
.tiles { display: grid; grid-template-columns: repeat(5, var(--tile-size)); gap: var(--tile-gap); }
.tile { width: var(--tile-size); height: var(--tile-size); border-radius: 8px; border: 2px solid var(--tile-border); background: var(--tile); color: #fff; display: grid; place-items: center; font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 800; text-transform: uppercase; user-select: none; touch-action: none; position: relative; transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease, background 140ms ease, opacity 120ms ease; -webkit-user-select: none; }
.tile.green { background: var(--green); border-color: var(--green); }
.tile.yellow { background: var(--yellow); border-color: var(--yellow); }
.tile.grey { background: var(--grey); border-color: var(--grey); }
.tile.selected { box-shadow: 0 0 0 3px rgba(255,255,255,0.18); transform: scale(1.04); z-index: 2; }
.tile.drag-source { opacity: 0.28; transform: scale(0.98); }
.tile.drop-target { box-shadow: 0 0 0 3px rgba(255,255,255,0.24), 0 0 20px rgba(255,255,255,0.12); transform: scale(1.06); z-index: 2; }
.tile.solved { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12); }
.drag-ghost { position: fixed; width: var(--tile-size); height: var(--tile-size); border-radius: 8px; border: 2px solid rgba(255,255,255,0.22); color: #fff; display: grid; place-items: center; font-size: clamp(1.25rem, 3vw, 2rem); font-weight: 800; text-transform: uppercase; pointer-events: none; z-index: 9999; transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 16px 30px rgba(0,0,0,0.35); }
.drag-ghost.green { background: var(--green); border-color: var(--green); }
.drag-ghost.yellow { background: var(--yellow); border-color: var(--yellow); }
.drag-ghost.grey { background: var(--grey); border-color: var(--grey); }
.row.solved { border-color: rgba(106,170,100,0.4); background: #171d17; }
.footer { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.meta-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.82rem; opacity: 0.9; }
.meta-footer a { color: var(--muted); text-decoration: none; }
.meta-footer a:hover { color: var(--text); text-decoration: underline; }
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.6); padding: 20px; }
.overlay.show { display: flex; }
.modal { width: min(92vw, 420px); background: var(--panel); border: 1px solid #2b2c30; border-radius: 18px; padding: 24px; text-align: center; box-shadow: 0 20px 40px rgba(0,0,0,0.35); }
.modal h2 { margin: 0 0 8px; font-size: 2rem; letter-spacing: 0.04em; }
.modal p { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.win-summary { display: grid; gap: 10px; color: var(--muted); line-height: 1.5; margin-bottom: 18px; }
.swap-score { font-weight: 800; }
.swap-score.good { color: var(--green); } .swap-score.mid { color: var(--yellow); } .swap-score.bad { color: #e05d5d; }
.word-list { display: grid; gap: 4px; justify-items: center; font-weight: 700; letter-spacing: 0.04em; }
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .panel { position: static; order: 1; }
  .panel-top { order: 1; }
  .board-wrap { order: 2; }
  .panel-bottom { order: 3; }
}
@media (max-width: 560px) {
  body { padding-top: 10px; }
  .app { width: 100%; padding: 12px; gap: 12px; display: flex; flex-direction: column; }
  .panel, .board-wrap { width: 100%; border-radius: 16px; }
  .panel { display: contents; }
  .panel-top, .panel-bottom, .board-wrap { width: 100%; background: var(--panel); border: 1px solid #242528; border-radius: 16px; box-shadow: 0 12px 30px var(--shadow); padding: 16px; }
  .board-wrap { box-shadow: 0 16px 36px rgba(0,0,0,0.34); border-color: #2d2f35; width: 100%; max-width: none; padding: 14px; }
  .panel-top, .panel-bottom { gap: 12px; }
  h1 { font-size: 1.9rem; text-align: center; }
  .title-bar { min-height: 36px; }
  .tag { font-size: 0.95rem; line-height: 1.35; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .controls { justify-content: flex-start; }
  .rows { display: flex; flex-direction: column; width: 100%; align-items: stretch; }
  .row { display: block; width: 100%; max-width: none; padding: 8px; border-radius: 14px; }
  .tiles { display: grid; justify-content: stretch; grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; }
  .tile { width: 100%; height: min(17vw, 62px); min-height: 50px; border-radius: 7px; }
  .board-header { padding-right: 44px; margin-bottom: 8px; }
  .message { font-size: 0.82rem; line-height: 1.25; opacity: 0.88; }
  #soundBtn { top: 50%; right: 0; }
  .footer { font-size: 0.88rem; line-height: 1.35; }
}
