:root {
  --bg-a: #f3efe4;
  --bg-b: #ece5d2;
  --text: #1f1f1f;
  --panel: #fffdf8;
  --panel-line: #dfd4bd;
  --input-bg: #fff;
  --input-line: #d9ccb0;
  --btn: #d8cfbc;
  --primary: #0b7285;
  --tile-face: #fffaf0;
  --tile-edge: #d4c4a1;
  --tile-back: #a08356;
  --free-glow: #20a4be;
}

body[data-theme="dark"] {
  --bg-a: #0b1114;
  --bg-b: #121c22;
  --text: #e7f1f6;
  --panel: #172127;
  --panel-line: #314851;
  --input-bg: #10191f;
  --input-line: #3d5c67;
  --btn: #22363f;
  --primary: #29c4d3;
  --tile-face: #243743;
  --tile-edge: #4e6f7d;
  --tile-back: #355060;
  --free-glow: #67e5ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: linear-gradient(150deg, var(--bg-a), var(--bg-b));
  color: var(--text);
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--panel-line);
  border-radius: 14px;
  padding: 16px;
}

.hidden {
  display: none;
}

.top-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
}

input {
  padding: 10px 12px;
  border: 1px solid var(--input-line);
  border-radius: 9px;
  background: var(--input-bg);
  color: var(--text);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.btn {
  border: 0;
  background: var(--btn);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn.primary {
  background: var(--primary);
  color: #062026;
}

.back-link {
  display: inline-block;
  margin-top: 10px;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.status {
  margin: 10px 0;
  font-weight: 700;
}

.players {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.player {
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--input-bg);
}

.player.me {
  border-left: 6px solid var(--primary);
}

.board-wrap {
  overflow: auto;
  padding-bottom: 10px;
}

.board {
  position: relative;
  width: 980px;
  height: 430px;
  margin: 0 auto;
  border: 2px solid var(--panel-line);
  border-radius: 12px;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), transparent);
}

.tile {
  position: absolute;
  width: 84px;
  height: 108px;
  border-radius: 12px;
  border: 2px solid var(--tile-edge);
  background: var(--tile-face);
  color: var(--text);
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.22);
}

.tile.free {
  box-shadow: 0 0 0 2px var(--free-glow), 0 7px 16px rgba(0, 0, 0, 0.22);
}

.tile.selected {
  outline: 3px solid #ffb703;
  outline-offset: -3px;
}

.tile:not(.free) {
  opacity: 0.72;
}

.tile.matched {
  opacity: 0;
  pointer-events: none;
}

.message {
  min-height: 24px;
  margin-top: 10px;
  font-weight: 700;
}
