/* ═══════════════════════════════════════════
   style.css  ― グリーン／ネイビー高級感テーマ
   ═══════════════════════════════════════════ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* グリーンテーマ（プレイ画面準拠） */
  --clr-bg:         #1a2e1e;
  --clr-surface:    rgba(255,255,255,0.07);
  --clr-primary:    #4a9e70;
  --clr-primary-dk: #2d7a52;
  --clr-accent:     #C87D52;
  --clr-text:       #e8f5ea;
  --clr-text-sub:   rgba(200,240,210,0.65);
  --clr-border:     rgba(100,200,140,0.20);
  --clr-shadow:     rgba(0,0,0,0.35);
  /* ネイビーテーマ（タイトル・handoff） */
  --clr-navy:       #0c1828;
  --clr-gold:       #c8a84b;
  --clr-gold-lt:    #e8d080;
  --font: 'Hiragino Kaku Gothic ProN','Hiragino Sans','Noto Sans JP',sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --ease: 180ms ease;
}

html, body {
  height: 100%;
  height: 100dvh;
  width: 100%;
  font-family: var(--font);
  background: var(--clr-bg);
  color: var(--clr-text);
  font-size: 15px;
  line-height: 1.6;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
}

#app {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── Audio button ── */
#btn-audio {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 300;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.30);
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  transition: transform var(--ease);
}
#btn-audio:active { transform: scale(0.9); }

/* ═══ Screens ═══ */
.screen {
  display: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  flex-direction: column;
  overflow: hidden;
}
.screen--active {
  display: flex;
  animation: fadeInUp .18s ease both;
}

/* ═══ Buttons ═══ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--ease), box-shadow var(--ease), background var(--ease);
  user-select: none;
}
.btn:active { transform: scale(0.96); }

.btn--primary {
  background: linear-gradient(135deg, #4a9e70 0%, #2d7a52 100%);
  color: #fff;
  box-shadow: 0 4px 16px rgba(45,122,82,0.45);
  width: 100%;
  padding: 15px;
  font-size: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255,255,255,0.15);
  letter-spacing: 0.03em;
}
.btn--primary:hover { background: linear-gradient(135deg, #5ab080 0%, #3d8a62 100%); }

.btn--secondary {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  border: 1.5px solid rgba(255,255,255,0.30);
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
}
.btn--secondary:hover { background: rgba(255,255,255,0.15); }

.btn--ghost {
  background: transparent;
  color: rgba(200,240,210,0.75);
  font-size: 14px;
  padding: 8px 12px;
}

.btn--pass {
  background: linear-gradient(135deg, #4a8a6a 0%, #3a7058 100%);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  flex: 1 1 calc(50% - 4px);
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  transition: all var(--ease);
}
.btn--pass:hover { background: linear-gradient(135deg, #5a9a7a 0%, #4a8068 100%); }
.btn--pass:active { transform: scale(0.96); }

.btn--discard {
  background: rgba(60,40,30,0.6);
  color: rgba(255,220,180,0.85);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  width: 100%;
  margin-top: 4px;
  border: 1px solid rgba(255,180,100,0.25);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

button:disabled { opacity: 0.4; pointer-events: none; }

/* ═══ Shared header ═══ */
.screen-header {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 8px;
  background: rgba(0,0,0,0.30);
  border-bottom: 1px solid rgba(100,200,140,0.15);
  flex-shrink: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.screen-header__title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  text-align: center;
  color: var(--clr-gold-lt);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  letter-spacing: 0.04em;
}

/* ═══ Title screen ═══ */
.title-screen {
  position: relative;
  background: var(--clr-navy);
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  overflow: hidden;
}
.title-screen__bg {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  background-image: url('card-pic/bk-full.jpg');
  background-repeat: no-repeat;
  background-position: center center;
  background-size: cover;
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.title-screen__top {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40vh;
}
.title-screen__top-img {
  width: 116px;
  height: 116px;
  object-fit: cover;
  border-radius: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.55), 0 0 0 2px rgba(200,168,75,0.4);
  display: block;
}
.title-logo {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  min-height: 0;
}
.title-logo__img {
  width: min(96%, 380px);
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 20px rgba(0,0,0,0.7));
}
.title-buttons {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 80%;
  max-width: 280px;
  height: 40vh;
  flex-shrink: 0;
}

/* ═══ Handoff screen ═══ */
.handoff-screen {
  position: relative;
  background: var(--clr-navy);
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}
.handoff-screen > * {
  position: relative;
  z-index: 1;
}
.handoff-screen h2 {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.7);
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}
.handoff-screen p {
  font-size: 14px;
  color: rgba(255,255,255,0.80);
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.handoff-card-icon {
  width: 130px;
  height: 185px;
  background-image: url('card-pic/bk.png');
  background-size: cover;
  background-position: center;
  border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.65), 0 0 0 2px rgba(200,168,75,0.35);
  margin-bottom: 36px;
  flex-shrink: 0;
}
.handoff-countdown {
  font-size: 13px;
  color: rgba(200,235,215,0.90);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  margin-top: 14px;
  min-height: 20px;
}

/* ═══ Rules screen ═══ */
.rules-screen { background: var(--clr-bg); }
.rules-content {
  padding: 20px 16px 48px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}
.rules-section { margin-bottom: 28px; }
.rules-section h3 {
  font-size: 14px; font-weight: 700;
  color: #7dd8a0;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 2px solid #4a9e70;
  display: inline-block;
}
.rules-section p, .rules-section li { font-size: 14px; line-height: 1.8; color: rgba(220,240,225,0.9); }
.rules-section ul, .rules-section ol { padding-left: 20px; }
.rules-section li { margin-bottom: 4px; }

/* ═══ Setup screen ═══ */
.setup-screen {
  background: radial-gradient(ellipse at 50% 0%, #2a5038 0%, #1a3028 50%, #121e18 100%);
}
.setup-content {
  padding: 20px 16px 48px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.setup-section h3 {
  font-size: 12px; font-weight: 700;
  color: rgba(160,220,180,0.75);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}
.player-count-row, .copy-count-row { display: flex; gap: 8px; }
.player-count-btn, .copy-count-btn {
  flex: 1;
  padding: 12px 0;
  border: 1.5px solid rgba(100,200,140,0.25);
  border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05);
  color: rgba(200,240,210,0.80);
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: all var(--ease);
}
.player-count-btn.active, .copy-count-btn.active {
  border-color: #4a9e70;
  background: linear-gradient(135deg, #4a9e70, #2d7a52);
  color: #fff;
  box-shadow: 0 2px 10px rgba(74,158,112,0.4);
}
#deck-info { font-size: 12px; color: var(--clr-text-sub); margin-top: 6px; }
.name-input-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.name-input-row label { font-size: 13px; color: rgba(160,220,180,0.75); width: 80px; flex-shrink: 0; }
.name-input {
  flex: 1;
  border: 1.5px solid rgba(100,200,140,0.25);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font);
  background: rgba(255,255,255,0.07);
  color: #e8f5ea;
  transition: border-color var(--ease);
}
.name-input:focus { outline: none; border-color: #4a9e70; }
.name-input::placeholder { color: rgba(200,240,210,0.35); }

/* ═══ Game screen ═══ */
.game-screen {
  background: radial-gradient(ellipse at 50% 30%, #3a6b4a 0%, #2a5038 55%, #1e3a28 100%);
}
.game-header {
  padding: 10px 56px 10px 16px;
  background: rgba(0,0,0,0.30);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}
.game-header__turn {
  font-size: 14px;
  font-weight: 700;
  color: #E8F5EA;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.board { position: relative; flex: 1; min-height: 0; }
.center-piles {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 24px;
  align-items: center;
}
.pile-wrapper { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.pile-label {
  font-size: 10px;
  color: rgba(255,255,255,0.75);
  font-weight: 700;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}
.pile {
  width: 58px; height: 82px;
  border-radius: var(--radius-sm);
  border: 2px dashed rgba(255,255,255,0.30);
  background: rgba(0,0,0,0.20);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--ease);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.2);
}
.pile--has-cards {
  background-image: url('card-pic/bk.png');
  background-size: cover;
  background-position: center;
  border: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.40), 0 1px 0 rgba(255,255,255,0.12) inset;
}
.pile--discard-active {
  background: rgba(120,170,130,0.5);
  border: 2px solid rgba(150,210,160,0.5);
}
.pile__count { font-size: 20px; font-weight: 700; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }
.pile--has-cards .pile__count {
  background: rgba(0,0,0,0.45);
  border-radius: 50%;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.pile--empty .pile__count { color: rgba(255,255,255,0.35); font-size: 12px; }

.player-area { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.player-area--bottom   { bottom: 8px;  left: 50%;  transform: translateX(-50%); }
.player-area--left     { left: 6px;    top: 50%;   transform: translateY(-50%); }
.player-area--right    { right: 6px;   top: 50%;   transform: translateY(-50%); }
.player-area--top      { top: 8px;     left: 50%;  transform: translateX(-50%); }
.player-area--top-left  { top: 10px; left: 10px; }
.player-area--top-right { top: 10px; right: 10px; }

.player-area__name {
  font-size: 11px; font-weight: 700;
  color: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.35);
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.15);
}
.player-area__name--current {
  color: #A8E6B8;
  background: rgba(40,120,70,0.55);
  border-color: rgba(168,230,184,0.4);
}
.player-area__pile-info { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.pile-badge { font-size: 9px; padding: 1px 5px; border-radius: 10px; white-space: nowrap; }
.pile-badge--individual { background: rgba(200,125,82,0.3); color: #F5C090; }
.pile-badge--hand       { background: rgba(107,143,166,0.3); color: #A8D0E8; }

.hand-area {
  background: linear-gradient(to bottom, rgba(20,40,28,0.85), rgba(15,30,20,0.95));
  border-top: 1px solid rgba(255,255,255,0.10);
  padding: 10px 10px 12px;
  flex-shrink: 0;
  backdrop-filter: blur(8px);
}
.turn-info { margin-bottom: 6px; }
#turn-prompt { font-size: 13px; font-weight: 700; color: #A8E6B8; margin-bottom: 1px; }
#turn-instruction { font-size: 11px; color: rgba(255,255,255,0.55); }

#hand-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, auto);
  gap: 6px;
  padding: 6px 2px 4px;
}
#pass-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ═══ Game end screen ═══ */
.game-end-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
  padding: 40px 24px;
  background: radial-gradient(ellipse at 50% 30%, #3a6b4a 0%, #2a5038 55%, #1e3a28 100%);
}
.game-end-screen h2 { font-size: 24px; font-weight: 700; color: #A8E6B8; text-shadow: 0 2px 8px rgba(0,0,0,0.5); }
.game-end-screen__sub { color: rgba(232,245,234,0.85); font-size: 14px; line-height: 1.7; }

/* ═══ Scoring screen ═══ */
.scoring-screen {
  background: radial-gradient(ellipse at 50% 0%, #2a5038 0%, #1a3028 50%, #121e18 100%);
}
.scoring-content {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.scoring-section-label {
  font-size: 11px; font-weight: 700;
  color: rgba(160,220,180,0.70);
  text-transform: uppercase; letter-spacing: .06em;
  margin-bottom: 6px; margin-top: 14px;
}
#scoring-hand, .scoring-pile-group__cards { display: flex; flex-wrap: wrap; gap: 6px; }
.scoring-pile-group { margin-bottom: 12px; }
.scoring-pile-group__label { font-size: 12px; color: rgba(180,230,200,0.65); margin-bottom: 4px; }

.scoring-highlight-btns { display: none; gap: 8px; margin-top: 14px; }
.hl-btn {
  flex: 1; padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid rgba(100,200,140,0.30);
  background: rgba(255,255,255,0.06);
  color: rgba(200,240,210,0.80);
  font-size: 13px; font-weight: 700;
  cursor: pointer; transition: all var(--ease);
}
.hl-btn--mutual { border-color: #5090c0; color: #80c0e0; }
.hl-btn--self   { border-color: #50a870; color: #80d0a0; }
.hl-btn--active.hl-btn--mutual { background: #2E6DA4; color: #fff; border-color: #2E6DA4; }
.hl-btn--active.hl-btn--self   { background: #1E7A42; color: #fff; border-color: #1E7A42; }

#scoring-result {
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-top: 14px;
  border: 1px solid rgba(100,200,140,0.18);
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 7px 0;
  border-bottom: 1px solid rgba(100,200,140,0.15);
  font-size: 14px;
  color: rgba(220,240,225,0.9);
}
.score-row:last-child { border-bottom: none; }
.score-row--total { font-size: 16px; padding-top: 10px; }
.score-row__label-wrap { display: flex; flex-direction: column; gap: 2px; }
.score-row__sublabel { font-size: 10px; color: rgba(180,230,200,0.55); font-weight: 400; }
.score-row__value { font-weight: 600; white-space: nowrap; padding-top: 1px; }

.scoring-actions {
  padding: 10px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  border-top: 1px solid rgba(100,200,140,0.15);
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(8px);
}
#scoring-instruction { font-size: 12px; color: rgba(160,220,180,0.65); text-align: center; }

.btn--save {
  background: rgba(255,255,255,0.07);
  color: rgba(200,240,210,0.85);
  border: 1.5px solid rgba(100,200,140,0.30);
  border-radius: var(--radius-md);
  padding: 10px;
  font-size: 13px;
  width: 100%;
}

/* ═══ Final screen ═══ */
.final-screen {
  background: radial-gradient(ellipse at 50% 0%, #2a5038 0%, #1a3028 50%, #121e18 100%);
}
.final-content {
  padding: 20px 16px 16px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.final-content > p { color: rgba(180,230,200,0.65); }

.final-score-row {
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 8px;
  display: grid;
  grid-template-columns: 36px 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 8px;
  border: 1px solid rgba(100,200,140,0.15);
}
.final-score-row--winner {
  border-color: var(--clr-gold);
  background: rgba(200,168,75,0.12);
  box-shadow: 0 2px 12px rgba(200,168,75,0.20);
}
.final-score-row__rank  { font-size: 22px; grid-row: 1/3; display: flex; align-items: center; }
.final-score-row__name  { font-size: 15px; font-weight: 700; align-self: end; color: #e8f5ea; }
.final-score-row__total { font-size: 20px; font-weight: 700; color: var(--clr-gold-lt); grid-row: 1/3; display: flex; align-items: center; }
.final-score-row__detail { font-size: 11px; color: rgba(180,230,200,0.55); grid-column: 2; }

.final-actions { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }

/* ═══ Reflection screen ═══ */
.reflection-screen {
  background: radial-gradient(ellipse at 50% 0%, #2a5038 0%, #1a3028 50%, #121e18 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.reflection-inner {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100%; padding: 40px 24px; gap: 20px;
}
.reflection-text {
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 20px;
  border-left: 4px solid #4a9e70;
  width: 100%;
}
.reflection-text p { font-size: 15px; line-height: 1.8; margin-bottom: 12px; color: rgba(220,240,225,0.85); }
.reflection-text p:last-child { margin-bottom: 0; color: #a0d0b0; font-weight: 700; }
.reflection-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.reflection-results-section { width: 100%; }
.reflection-results-section h3 { font-size: 13px; color: rgba(160,220,180,0.65); margin-bottom: 8px; text-align: center; }
.reflection-result-btns { display: flex; flex-direction: column; gap: 8px; }
.btn--result-view {
  background: rgba(255,255,255,0.06);
  color: rgba(200,240,210,0.85);
  border: 1.5px solid rgba(100,200,140,0.30);
  border-radius: var(--radius-md);
  padding: 10px; font-size: 14px; font-weight: 700;
  cursor: pointer; width: 100%; transition: all var(--ease);
}
.btn--result-view:active { background: #4a9e70; color: #fff; }

/* ═══ Modal ═══ */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.70);
  z-index: 200;
  align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.modal--visible { display: flex; }
.modal__inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
#btn-modal-close {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  padding: 8px 28px;
  font-size: 14px;
}

/* ═══ Toast ═══ */
#toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(20,40,28,0.95);
  color: #e8f5ea;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 400;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
  border: 1px solid rgba(100,200,140,0.25);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
#toast.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══ Animations ═══ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
