:root {
  --red: #c0392b;
  --gold: #e2b23c;
  --dark: #2b1a12;
  --paper: #fff8ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  background: linear-gradient(160deg, #7a1f1f, #3a0f0f);
  color: var(--dark);
  min-height: 100vh;
}

.screen { max-width: 720px; margin: 0 auto; padding: 20px; }
.hidden { display: none !important; }

h1 { color: var(--paper); text-align: center; text-shadow: 0 2px 4px rgba(0,0,0,.4); }
h2 { margin-top: 0; color: var(--red); }

.card-box {
  background: var(--paper);
  border: 3px solid var(--gold);
  border-radius: 14px;
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}

label { display: block; font-size: 13px; margin-bottom: 4px; color: #6b4226; }

input[type=text] {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 2px solid #d9c2a0;
  font-size: 16px;
  margin-bottom: 10px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: bold;
  margin: 4px 4px 4px 0;
}
button.primary { background: var(--red); color: #fff; }
button.warn { background: #333; color: #ffd54f; }
button.ghost { background: #eee; color: #444; }
button:disabled { opacity: .5; cursor: not-allowed; }

.join-row { display: flex; gap: 8px; }
.join-row input { margin-bottom: 0; }
.error { color: var(--red); font-weight: bold; min-height: 20px; }
.hint { font-size: 12px; color: #888; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  color: var(--paper); margin-bottom: 10px;
}
.code { font-weight: bold; letter-spacing: 3px; color: var(--gold); font-size: 20px; }

#playerList { list-style: none; padding: 0; }
#playerList li { padding: 6px 0; border-bottom: 1px dashed #d9c2a0; }

.menu-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 8px; }
.menu-item {
  background: #fdeecb; border: 1px solid var(--gold); border-radius: 8px;
  padding: 6px 8px; font-size: 13px;
}
.menu-item b { display: block; color: var(--red); }

.players-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.player-chip {
  background: #fff; border-radius: 20px; padding: 6px 12px; font-size: 13px;
  border: 2px solid var(--gold); display: flex; gap: 6px; align-items: center;
}
.player-chip.me { border-color: var(--red); background: #ffe9e0; }
.player-chip.finished { background: #d7f5d0; border-color: #4caf50; }
.player-chip .cnt { font-weight: bold; color: var(--red); }

.tray-area {
  background: #4a1c10;
  border-radius: 50% / 20%;
  border: 6px solid #d9a441;
  min-height: 140px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px;
  padding: 20px;
  margin-bottom: 8px;
  position: relative;
}
.tray { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.last-call {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: var(--gold); color: #3a0f0f; font-weight: bold; padding: 4px 14px;
  border-radius: 20px; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.4);
  opacity: 0; transition: opacity .15s;
}
.last-call.show { opacity: 1; }

.chip {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; font-size: 13px; text-align: center;
  background: radial-gradient(circle at 30% 30%, #fff7e0, #f3d27a);
  border: 3px solid #b8860b;
  box-shadow: 0 2px 4px rgba(0,0,0,.4);
  animation: pop .18s ease-out;
}
.chip.cancel { background: radial-gradient(circle at 30% 30%, #ffdcdc, #e08080); color: #7a0000; border-color: #a30000; }

@keyframes pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.hand-area { margin-top: 10px; }
.hand { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; padding: 10px; background: rgba(255,255,255,.08); border-radius: 12px; }
.hand .chip { width: 64px; height: 64px; cursor: pointer; transition: transform .1s; font-size: 14px; }
.hand .chip:hover { transform: translateY(-4px) scale(1.05); }
.hand .chip:active { transform: scale(.9); }

.hand-toolbar { display: flex; justify-content: center; margin-bottom: 8px; }
.hand-mode-toggle { display: inline-flex; background: rgba(255,255,255,.15); border-radius: 20px; padding: 3px; gap: 2px; }
.mode-btn { background: transparent; color: var(--paper); margin: 0; padding: 6px 16px; border-radius: 16px; font-size: 13px; }
.mode-btn.active { background: var(--gold); color: #3a0f0f; }

.hand-slide {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 16px 10px; background: rgba(255,255,255,.08); border-radius: 12px;
}
.slide-info { color: var(--paper); font-size: 13px; opacity: .85; }
.slide-card-area { display: flex; align-items: center; justify-content: center; gap: 16px; }
.slide-chip { width: 96px; height: 96px; font-size: 18px; }
.slide-chip.empty { background: transparent; border: 2px dashed rgba(255,255,255,.3); box-shadow: none; }
.nav-btn {
  width: 44px; height: 44px; border-radius: 50%; background: var(--paper); color: var(--red);
  font-size: 18px; padding: 0; display: flex; align-items: center; justify-content: center; margin: 0;
}
.nav-btn:active { transform: scale(.9); }

.controls { text-align: center; margin-top: 12px; }

#resultList { font-size: 16px; }
#resultList li { margin-bottom: 6px; }
