:root {
  --bg: #f4efe6;
  --bg-accent: #e6d9c4;
  --panel: #fbf7ef;
  --ink: #2f2a24;
  --muted: #75695a;
  --primary: #245d57;
  --primary-strong: #1a4742;
  --danger: #8a2e2e;
  --tile: #fff8ea;
  --hex: #e7dcc8;
  --hex-filled: #f2e7d2;
  --border: #c6b89f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 10% 10%, #fff5de 0%, var(--bg) 50%, var(--bg-accent) 100%);
}

.app-shell {
  width: min(1100px, 95vw);
  margin: 1.2rem auto 2rem;
}

.topbar {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(125deg, #f8f1e4, #ede2cf);
  padding: 0.9rem 1rem;
  margin-bottom: 0.9rem;
}

.topbar h1 {
  margin: 0;
  letter-spacing: 0.04em;
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.lang-picker select {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fffcf6;
  color: var(--ink);
  padding: 0.2rem 0.4rem;
}

.topbar p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.9rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.9rem;
}

.card {
  background: #fffaf0;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  display: grid;
  gap: 0.6rem;
}

h2,
h3 {
  margin-top: 0;
}

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.95rem;
}

input,
button {
  font: inherit;
}

input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  background: #fffcf6;
}

button {
  border: 1px solid var(--primary-strong);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  color: #fff;
  background: var(--primary);
  cursor: pointer;
}

button:hover {
  background: var(--primary-strong);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hex:disabled {
  opacity: 1;
  cursor: default;
}

button.danger {
  background: var(--danger);
  border-color: #6f2121;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.between {
  justify-content: space-between;
}

.wrap {
  flex-wrap: wrap;
}

.gap-sm {
  gap: 0.5rem;
}

.hidden {
  display: none;
}

.error {
  color: #8d2424;
  background: #ffefef;
  border: 1px solid #ddb3b3;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
}

.player-list,
.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.player-item,
.ranking-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff9ef;
  padding: 0.55rem 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.invite-copy-button {
  padding: 0.18rem 0.5rem;
  font-size: 0.82rem;
  margin-left: 0.35rem;
}

.invite-copy-status {
  margin-left: 0.35rem;
  font-weight: 700;
}

.tile-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--tile);
  min-width: 150px;
  min-height: 112px;
  padding: 0.5rem;
}

.tile-preview-face {
  position: relative;
  width: 110px;
  height: 96px;
  border: 1px solid #ae9f88;
  clip-path: polygon(25% 5%, 75% 5%, 95% 50%, 75% 95%, 25% 95%, 5% 50%);
  background: var(--hex-filled);
  overflow: hidden;
}

.tile-preview-unknown {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: #4a4034;
}

.game-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(230px, 320px);
  gap: 1rem;
}

.board {
  position: relative;
  min-height: 500px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: linear-gradient(180deg, #fbf4e5, #f5ecd9);
}

.hex {
  position: absolute;
  width: 96px;
  height: 84px;
  border: 1px solid #ae9f88;
  clip-path: polygon(25% 5%, 75% 5%, 95% 50%, 75% 95%, 25% 95%, 5% 50%);
  background: var(--hex);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #3d3227;
}

.hex.clickable {
  cursor: pointer;
  border-color: #768f6e;
  background: #edf4e5;
}

.hex.filled {
  background: var(--hex-filled);
}

.empty-label {
  font-size: 0.72rem;
  color: #635541;
  opacity: 0.9;
}

.tile-face {
  position: absolute;
  inset: 0;
}

.tile-face.compact {
  transform: scale(0.92);
  transform-origin: center;
}

.tile-path {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 78%;
  height: 8px;
  background-color: var(--tile-value-color, #2c3e50);
  transform-origin: center;
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.path-v {
  transform: translate(-50%, -50%) rotate(90deg);
}

.path-u {
  width: 82%;
  transform: translate(-50%, -50%) rotate(-30deg);
}

.path-d {
  width: 82%;
  transform: translate(-50%, -50%) rotate(30deg);
}

.tile-chip {
  position: absolute;
  width: 21px;
  height: 21px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--tile-value-color, #2c3e50);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.65);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.chip-v {
  left: 50%;
  top: 6%;
  transform: translateX(-50%);
}

.chip-u {
  left: 14%;
  top: 63%;
}

.chip-d {
  right: 14%;
  top: 63%;
}

.val-1 {
  --tile-value-color: #332288;
}

.val-2 {
  --tile-value-color: #88ccee;
}

.val-3 {
  --tile-value-color: #44aa99;
}

.tile-chip.val-2 {
  color: #2f2a24;
  text-shadow: none;
}

.val-4 {
  --tile-value-color: #117733;
}

.val-5 {
  --tile-value-color: #999933;
}

.val-6 {
  --tile-value-color: #ddcc77;
}

.tile-chip.val-6 {
  color: #2f2a24;
  text-shadow: none;
}

.val-7 {
  --tile-value-color: #cc6677;
}

.val-8 {
  --tile-value-color: #882255;
}

.val-9 {
  --tile-value-color: #aa4499;
}

.revealed-grid {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem;
}

.revealed-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff9ef;
  padding: 0.7rem;
}

.score-components {
  margin: 0.5rem 0 0.6rem;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.3;
  word-break: break-word;
}

.mini-board {
  position: relative;
  min-height: 360px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f8efd9;
}

.mini-board .hex {
  transform: scale(0.77);
  transform-origin: top left;
}

@media (max-width: 860px) {
  .game-grid {
    grid-template-columns: 1fr;
  }

  .board {
    min-height: 450px;
  }

  .hex {
    width: 82px;
    height: 72px;
  }

  .tile-chip {
    width: 18px;
    height: 18px;
    font-size: 0.65rem;
  }
}
