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

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

:root {
  --pink:    #E8409A;
  --sky:     #87CEEB;
  --orange:  #FFB347;
  --bg:      #FFF5F9;
  --text:    #333333;
  --p1:      #FF69B4;
  --p2:      #87CEEB;
  --p3:      #FFD700;
  --p4:      #C8A2C8;
  --shadow:  0 4px 20px rgba(232,64,154,0.15);
  --radius:  20px;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =================== LOBBY =================== */
.lobby-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #FFF0FA 0%, #E8F4FF 100%);
}

.lobby-logo {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--pink);
  text-shadow: 2px 2px 0 #FFD6EC;
  letter-spacing: -1px;
  text-align: center;
  margin-bottom: 6px;
}

.lobby-sub {
  font-size: 0.95rem;
  color: #999;
  text-align: center;
  margin-bottom: 36px;
}

.lobby-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 32px 28px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.lobby-card h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px dashed #FFD6EC;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.input-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #888;
}

input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #FFD6EC;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: #FFFAFC;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus { border-color: var(--pink); }
input[type="text"]::placeholder { color: #ddd; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
  width: 100%;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, #E8409A, #FF69B4);
  color: #fff;
  box-shadow: 0 4px 14px rgba(232,64,154,0.4);
}
.btn-secondary {
  background: linear-gradient(135deg, var(--sky), #6BB8E8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(135,206,235,0.4);
}
.btn-orange {
  background: linear-gradient(135deg, var(--orange), #FF9520);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255,179,71,0.4);
}
.btn-gray {
  background: #f0f0f0;
  color: #666;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.82rem;
  border-radius: 10px;
  width: auto;
}

.divider {
  text-align: center;
  color: #ccc;
  font-size: 0.8rem;
  margin: 20px 0;
  position: relative;
}
.divider::before, .divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: #FFD6EC;
}
.divider::before { left: 0; }
.divider::after { right: 0; }

.waiting-list {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #FFF0FA;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.room-id-display {
  background: #FFF0FA;
  border: 2px dashed #FFB6DE;
  border-radius: 12px;
  padding: 12px 16px;
  text-align: center;
  margin-bottom: 16px;
}
.room-id-display .label { font-size: 0.75rem; color: #999; }
.room-id-display .code {
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--pink);
}

/* =================== GAME LAYOUT =================== */
.game-wrap {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

.game-header {
  background: linear-gradient(135deg, var(--pink), #FF90C4);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 2px 12px rgba(232,64,154,0.3);
}

.game-title {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.5px;
}

.turn-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.game-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  min-height: 0;
}

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

/* Board area */
.board-area {
  background: #E8F4FF;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

#board-svg {
  width: 100%;
  max-width: 760px;
  height: auto;
  cursor: default;
}

/* Side panel */
.side-panel {
  background: #fff;
  border-left: 2px solid #FFE8F5;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: calc(100vh - 56px);
}

.panel-section {
  padding: 14px 16px;
  border-bottom: 2px dashed #FFE8F5;
}

.panel-section h3 {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Resources */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.res-cell {
  background: #FFF5F9;
  border-radius: 8px;
  padding: 6px 4px;
  text-align: center;
  font-size: 0.7rem;
}
.res-cell .emoji { font-size: 1.1rem; display: block; }
.res-cell .count {
  font-size: 1rem;
  font-weight: 900;
  color: var(--pink);
}

/* Action buttons - 2-column grid */
.action-btns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.action-btn-sm {
  padding: 7px 4px !important;
  font-size: 0.76rem !important;
  border-radius: 10px !important;
  width: 100% !important;
}

/* Player list (compact) */
.player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid #FFF0FA;
}
.player-row:last-child { border-bottom: none; }
.player-color-bar {
  width: 4px;
  height: 26px;
  border-radius: 3px;
  flex-shrink: 0;
}
.player-info { flex: 1; min-width: 0; }
.player-name { font-size: 0.78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-res { font-size: 0.65rem; color: #999; }
.player-vp { font-size: 1rem; font-weight: 900; color: var(--pink); }

/* Dice display */
.dice-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: #FFF5F9;
  border-radius: 12px;
  margin-bottom: 10px;
  min-height: 50px;
}
.die {
  width: 36px;
  height: 36px;
  background: #fff;
  border: 2px solid #FFB6DE;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--pink);
  box-shadow: 0 2px 6px rgba(232,64,154,0.2);
}
.dice-total {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--pink);
}

/* Log */
.game-log {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}
.log-entry {
  padding: 5px 16px;
  font-size: 0.75rem;
  color: #666;
  border-bottom: 1px solid #FFF0FA;
  line-height: 1.4;
}
.log-entry.mine { color: var(--pink); font-weight: 700; }

/* Phase banner */
.phase-banner {
  padding: 8px 16px;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  border-radius: 10px;
  margin-bottom: 8px;
}
.phase-myturn { background: #FFF0FA; color: var(--pink); }
.phase-waiting { background: #F0F8FF; color: var(--sky); }

/* =================== MODALS =================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--pink);
  margin-bottom: 16px;
  text-align: center;
}

.trade-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.trade-res {
  border: 2px solid #FFD6EC;
  border-radius: 12px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.trade-res.selected { border-color: var(--pink); background: #FFF0FA; }
.trade-res .emoji { font-size: 1.6rem; display: block; }
.trade-res .name { font-size: 0.7rem; color: #888; }
.trade-res .count { font-size: 0.75rem; font-weight: 700; color: var(--pink); }

.discard-counter {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}
.discard-res {
  background: #FFF5F9;
  border: 2px solid #FFD6EC;
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
}
.discard-res .emoji { font-size: 1.2rem; display: block; }
.discard-res .my-count { font-size: 0.75rem; font-weight: 700; color: #666; }
.discard-res .sel-count { font-size: 0.9rem; font-weight: 900; color: var(--pink); }

.steal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.steal-player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid #FFD6EC;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.steal-player:hover { border-color: var(--pink); background: #FFF0FA; }

/* =================== TOAST =================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; }

/* =================== SVG STYLES =================== */
.vertex-spot {
  cursor: pointer;
  transition: r 0.1s;
}
.vertex-spot:hover { filter: brightness(1.1); }
.edge-hit { cursor: pointer; }
.tile-hit { cursor: pointer; }

/* =================== WINNER BANNER =================== */
.winner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(232,64,154,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 150;
  color: #fff;
  text-align: center;
  padding: 24px;
}
.winner-overlay.hidden { display: none; }
.winner-emoji { font-size: 5rem; margin-bottom: 12px; }
.winner-title { font-size: 2rem; font-weight: 900; margin-bottom: 8px; }
.winner-name { font-size: 1.4rem; font-weight: 700; opacity: 0.9; }
