@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700;900&family=Shippori+Mincho+B1:wght@400;700;800&display=swap');

:root {
  --felt: #1a3a2a;
  --felt-light: #1e4532;
  --felt-dark: #0f2218;
  --gold: #c9a84c;
  --gold-light: #f0d080;
  --gold-dark: #8a6a20;
  --red: #cc2222;
  --cream: #f5e6c8;
  --shadow: rgba(0,0,0,0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--felt-dark);
  font-family: 'Noto Serif JP', serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-image:
    radial-gradient(ellipse at center, #1e4532 0%, #0f2218 100%),
    repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.01) 10px, rgba(255,255,255,0.01) 20px);
}

/* ===== TITLE ===== */
#title-screen {
  text-align: center;
  position: absolute;
  z-index: 100;
}
#title-screen h1 {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 5rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 40px rgba(201,168,76,0.5), 3px 3px 0 var(--gold-dark);
  letter-spacing: 0.3em;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { text-shadow: 0 0 40px rgba(201,168,76,0.5), 3px 3px 0 var(--gold-dark); }
  50% { text-shadow: 0 0 80px rgba(201,168,76,0.9), 3px 3px 0 var(--gold-dark); }
}
#title-screen p {
  color: var(--cream);
  margin-top: 1rem;
  font-size: 1.1rem;
  opacity: 0.8;
  letter-spacing: 0.2em;
}
#start-btn {
  margin-top: 2.5rem;
  padding: 1rem 3rem;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold), var(--gold-dark));
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%);
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(201,168,76,0.4);
}
#start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(201,168,76,0.6);
}

/* ===== GAME SCREEN ===== */
#game-screen { display: none; width: 100vw; height: 100vh; position: relative; }

/* ===== TABLE (circle) ===== */
#table {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
  border-radius: 50%;
  background: radial-gradient(ellipse at 40% 35%, #2a5a3a, #1a3a2a 60%, #0f2218);
  border: 6px solid var(--gold-dark);
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 60px rgba(0,0,0,0.8),
    inset 0 0 80px rgba(0,0,0,0.4);
}

#table-label {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--gold);
  opacity: 0.18;
  letter-spacing: 0.5em;
  text-align: center;
  white-space: nowrap;
}

/* ===== PLAYER CARDS ===== */
.player-card {
  position: absolute;
  width: 200px;
  background: linear-gradient(160deg, #1e2e24, #111b16);
  border: 2px solid var(--gold-dark);
  border-radius: 4px;
  padding: 7px 10px;
  text-align: center;
  transition: all 0.3s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
.player-card.is-parent {
  border-color: var(--gold);
  box-shadow: 0 0 20px rgba(201,168,76,0.4), 0 4px 20px rgba(0,0,0,0.6);
}
.player-card.active {
  border-color: #ffee44;
  box-shadow: 0 0 30px rgba(255,238,68,0.5);
  transform: scale(1.08);
}
.player-card.bust { opacity: 0.4; }

/* positions around circle */
#player-0 { bottom: 20px; left: 50%; transform: translateX(-50%); }
#player-1 { left: 20px;   top: 50%;  transform: translateY(-50%); }
#player-2 { top: 20px;    left: 50%; transform: translateX(-50%); }
#player-3 { right: 20px;  top: 50%;  transform: translateY(-50%); }

.player-card.active#player-0 { transform: translateX(-50%) scale(1.04); }
.player-card.active#player-1 { transform: translateY(-50%) scale(1.04); }
.player-card.active#player-2 { transform: translateX(-50%) scale(1.04); }
.player-card.active#player-3 { transform: translateY(-50%) scale(1.04); }

.player-name {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.15em;
  margin-bottom: 1px;
}
.player-coins {
  font-size: 0.95rem;
  color: var(--cream);
  opacity: 0.85;
  letter-spacing: 0.1em;
}
.player-role {
  font-size: 0.8rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  min-height: 10px;
  margin-top: 1px;
}
.player-dice-area {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 4px;
  min-height: 46px;
  align-items: center;
}
.player-result {
  font-size: 0.9rem;
  color: #88ffaa;
  letter-spacing: 0.1em;
  min-height: 14px;
  margin-top: 2px;
}
.player-result.lose { color: #ff6666; }
.player-bet {
  font-size: 0.85rem;
  color: #ffdd88;
  letter-spacing: 0.1em;
  min-height: 14px;
  margin-top: 1px;
}
.player-bet.bold-bet  { color: #ff9966; font-weight: 700; }
.player-bet.safe-bet  { color: #88ddff; }
.player-bet.rand-bet  { color: #ccffaa; }
.player-yaku {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.2em;
  min-height: 18px;
  margin-top: 2px;
  text-shadow: 0 0 10px rgba(255,255,255,0.4);
}
.player-yaku.pinzoro { color: #ffdd44; text-shadow: 0 0 14px rgba(255,220,0,0.8); }
.player-yaku.sigoro  { color: #88ffcc; text-shadow: 0 0 12px rgba(100,255,180,0.7); }
.player-yaku.zoro    { color: #aaddff; text-shadow: 0 0 12px rgba(100,180,255,0.6); }
.player-yaku.hifumi  { color: #ff6666; text-shadow: 0 0 12px rgba(255,80,80,0.6); }
.player-yaku.menashi { color: #aaaaaa; }
.player-yaku-anim {
  animation: yakuCardPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes yakuCardPop {
  0%   { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

/* ===== DICE ===== */
.die {
  width: 42px; height: 42px;
  background: transparent;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0;
  box-shadow: none;
  position: relative;
  transition: transform 0.1s;
}
.die.rolling {
  animation: diceRoll 0.7s ease-out;
}
@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); }
  15%  { transform: rotate(-30deg) scale(1.2); }
  30%  { transform: rotate(60deg) scale(0.9); }
  45%  { transform: rotate(-45deg) scale(1.15); }
  60%  { transform: rotate(30deg) scale(1.05); }
  75%  { transform: rotate(-15deg) scale(0.95); }
  90%  { transform: rotate(8deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(1); }
}
/* Center dice display */
#center-dice-wrap {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
#center-dice {
  display: flex;
  gap: 10px;
}
#center-dice .die {
  width: 58px; height: 58px;
  font-size: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}
#center-roll-label {
  font-size: 0.85rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  opacity: 0.7;
  text-align: center;
}
#center-yaku {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 20px rgba(255,255,255,0.5);
  letter-spacing: 0.3em;
  min-height: 32px;
  text-align: center;
}

/* ===== LOG ===== */
#log-panel {
  position: fixed;
  bottom: 56px; left: 16px;
  width: 280px;
  max-height: 200px;
  background: rgba(10,20,14,0.92);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  overflow-y: auto;
  padding: 8px 12px;
  z-index: 40;
  display: none;
}
#log-panel.sp-visible {
  display: block;
}
.log-entry {
  font-size: 0.9rem;
  color: var(--cream);
  opacity: 0.8;
  padding: 2px 0;
  border-bottom: 1px solid rgba(201,168,76,0.08);
  letter-spacing: 0.05em;
}
.log-entry.highlight { color: var(--gold-light); opacity: 1; font-weight: 700; }
.log-entry.win { color: #88ffaa; opacity: 1; }
.log-entry.lose { color: #ff8888; opacity: 1; }

/* ===== BET PANEL ===== */
#bet-panel {
  position: fixed;
  bottom: 280px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10,22,16,0.97);
  border: 2px solid var(--gold);
  border-radius: 6px;
  padding: 14px 22px 16px;
  text-align: center;
  display: none;
  z-index: 50;
  box-shadow: 0 0 40px rgba(0,0,0,0.8), 0 0 20px rgba(201,168,76,0.15);
  min-width: 300px;
}
#bet-panel-info {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 8px 14px;
  margin-bottom: 12px;
}
.bet-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
  color: var(--cream);
  padding: 2px 0;
  letter-spacing: 0.1em;
}
.bet-info-row + .bet-info-row {
  border-top: 1px solid rgba(201,168,76,0.12);
  margin-top: 4px;
  padding-top: 4px;
}
.bi-label {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.2em;
}
#bet-info-coins { color: #ffdd88; font-weight: 700; font-size: 1.05rem; }
#bet-info-parent { color: var(--cream); }
#bet-panel p {
  color: var(--cream);
  font-size: 0.95rem;
  letter-spacing: 0.2em;
  margin-bottom: 10px;
}
.bet-btns { display: flex; gap: 8px; justify-content: center; }
.bet-btn {
  padding: 8px 16px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  transition: all 0.2s;
}
.bet-btn:hover:not(:disabled) { filter: brightness(1.2); transform: translateY(-1px); }
.bet-btn:disabled {
  background: linear-gradient(135deg, #333, #555);
  color: #777;
  cursor: not-allowed;
  opacity: 0.5;
}
#bet-panel-hint {
  font-size: 0.78rem;
  color: rgba(201,168,76,0.5);
  letter-spacing: 0.1em;
  margin-top: 10px;
}

/* ===== ROLL BUTTON ===== */
#roll-btn {
  position: fixed;
  bottom: 220px; left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 12px 40px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.4em;
  background: linear-gradient(135deg, #8a2020, #cc3333, #8a2020);
  color: var(--cream);
  border: 2px solid #ff6666;
  cursor: pointer;
  clip-path: polygon(14px 0, 100% 0, calc(100% - 14px) 100%, 0 100%);
  box-shadow: 0 0 30px rgba(204,50,50,0.4);
  transition: all 0.2s;
  z-index: 50;
}
#roll-btn:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 0 50px rgba(204,50,50,0.6);
}
#roll-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: translateX(-50%);
}

/* ===== ROUND INFO ===== */
#round-info {
  position: fixed;
  top: 16px; left: 16px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.1rem;
  color: var(--gold);
  letter-spacing: 0.2em;
  text-align: left;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  background: rgba(10,20,14,0.82);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 6px 14px;
  z-index: 50;
}

/* ===== PARENT BADGE ===== */
.parent-badge {
  display: block;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold-light), var(--gold-dark));
  color: #1a1a1a;
  padding: 3px 10px;
  margin: 4px auto 0;
  width: fit-content;
  letter-spacing: 0.4em;
  text-shadow: none;
  box-shadow: 0 0 12px rgba(201,168,76,0.6);
  clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  animation: parentGlow 1.5s ease-in-out infinite;
}
@keyframes parentGlow {
  0%,100% { box-shadow: 0 0 12px rgba(201,168,76,0.5); }
  50%      { box-shadow: 0 0 24px rgba(201,168,76,0.9); }
}

/* ===== YAKU REFERENCE ===== */
#yaku-panel {
  position: fixed;
  bottom: 56px; right: 16px;
  width: 220px;
  background: rgba(10,20,14,0.92);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  padding: 10px 14px;
  z-index: 40;
  display: none;
}
#yaku-panel.sp-visible {
  display: block;
}
#yaku-panel h3 {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 0.9rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  border-bottom: 1px solid var(--gold-dark);
  padding-bottom: 5px;
  margin-bottom: 6px;
}
.yaku-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: 0.82rem;
  color: var(--cream);
  border-bottom: 1px solid rgba(201,168,76,0.07);
  letter-spacing: 0.05em;
}
.yaku-row .yname { color: var(--gold-light); font-weight: 700; }
.yaku-row.special .yname { color: #ffcccc; }

/* ===== COIN ANIMATION ===== */
.coin-pop {
  position: absolute;
  font-size: 1.2rem;
  pointer-events: none;
  animation: coinFly 0.9s ease-out forwards;
  z-index: 200;
}
@keyframes coinFly {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(0,-60px) scale(0.5); opacity: 0; }
}

/* ===== RESULT OVERLAY ===== */
#result-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
#result-box {
  background: linear-gradient(160deg, #1a2e22, #0f1f16);
  border: 3px solid var(--gold);
  padding: 40px 60px;
  text-align: center;
  box-shadow: 0 0 80px rgba(201,168,76,0.3);
}
#result-box h2 {
  font-family: 'Shippori Mincho B1', serif;
  font-size: 2.5rem;
  color: var(--gold-light);
  letter-spacing: 0.4em;
  margin-bottom: 20px;
}
#result-box .rankings { text-align: left; margin-bottom: 24px; }
#result-box .rank-item {
  font-size: 1rem;
  color: var(--cream);
  padding: 6px 0;
  letter-spacing: 0.15em;
  border-bottom: 1px solid rgba(201,168,76,0.15);
}
#result-box .rank-item:first-child { color: var(--gold-light); font-weight: 700; font-size: 1.1rem; }
#result-box button {
  padding: 10px 32px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  background: linear-gradient(135deg, var(--gold-dark), var(--gold));
  color: #1a1a1a;
  border: none;
  cursor: pointer;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

/* ===== YAKU FLASH ===== */
.yaku-flash {
  animation: yakuAppear 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes yakuAppear {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== SHAKE (目なし) ===== */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
.shake { animation: shake 0.4s ease; }

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
  /* ラウンド情報とCPU弐の重なりを防ぐため下にずらす */
  #player-2 { top: 70px; }
  .player-card.active#player-2 { top: 70px; transform: translateX(-50%) scale(1.04); }
}

/* ===== HOME BUTTON ===== */
#home-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  padding: 6px 14px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  background: rgba(10,20,14,0.92);
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}
#home-btn:hover {
  background: rgba(201,168,76,0.15);
  border-color: var(--gold);
}

/* ===== PANEL TOGGLE BUTTONS ===== */
#log-toggle-btn, #yaku-toggle-btn {
  position: fixed;
  bottom: 16px;
  z-index: 50;
  padding: 9px 16px;
  font-family: 'Shippori Mincho B1', serif;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  background: rgba(10,20,14,0.95);
  color: var(--gold);
  border: 1px solid var(--gold-dark);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
#log-toggle-btn {
  left: 16px;
}
#yaku-toggle-btn {
  right: 16px;
}
#log-toggle-btn.active, #yaku-toggle-btn.active {
  background: rgba(201,168,76,0.2);
  border-color: var(--gold);
}