/* Hanabi - Cooperative Fireworks Card Game
   Mobile-first, Dracula-inspired theme */

/* ===== Base Styles ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--skills-bg);
  color: var(--skills-text);
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  max-width: 760px;
  margin: 0 auto;
}

/* ===== Game Container ===== */
#game-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 52px; /* Space for menu button */
}

/* ===== Hanabi Card Colors ===== */
:root {
  --hanabi-red: #FF5555;
  --hanabi-blue: #6272FF;
  --hanabi-green: #50FA7B;
  --hanabi-yellow: #F1FA8C;
  --hanabi-white: #F8F8F2;
}

/* ===== Token Bar (compact top strip) ===== */
#token-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.2rem;
  padding: 0.4rem 0.75rem;
  background: var(--skills-surface);
  border-bottom: 1px solid var(--skills-border);
  font-size: 0.95rem;
  font-weight: 600;
}

.token-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.token-item .val {
  font-variant-numeric: tabular-nums;
}

.token-item.fuse-danger .val {
  color: var(--hanabi-red);
  animation: pulse-danger 1s infinite;
}

@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Firework Piles ===== */
#fireworks-bar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--skills-surface);
  border-bottom: 1px solid var(--skills-border);
}

.firework-pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 44px;
}

.firework-pile .pile-value {
  font-size: 1.4rem;
  font-weight: bold;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.15);
  transition: transform 0.3s, box-shadow 0.3s;
}

.firework-pile .pile-value.complete {
  box-shadow: 0 0 12px rgba(255,255,255,0.3);
  transform: scale(1.05);
}

.firework-pile .pile-color {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}

.pile-red .pile-value { background: var(--hanabi-red); color: #1a1a2e; }
.pile-blue .pile-value { background: var(--hanabi-blue); color: #fff; }
.pile-green .pile-value { background: var(--hanabi-green); color: #1a1a2e; }
.pile-yellow .pile-value { background: var(--hanabi-yellow); color: #1a1a2e; }
.pile-white .pile-value { background: var(--hanabi-white); color: #1a1a2e; }

/* ===== Clue Feed (THE CENTERPIECE) ===== */
#clue-feed {
  flex: 0 0 auto;
  max-height: 28vh;
  min-height: 80px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  background: rgba(15, 52, 96, 0.3);
  border-bottom: 1px solid var(--skills-border);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#clue-feed::-webkit-scrollbar {
  width: 4px;
}
#clue-feed::-webkit-scrollbar-thumb {
  background: var(--skills-border);
  border-radius: 2px;
}

.clue-entry {
  padding: 0.4rem 0.6rem;
  margin-bottom: 0.35rem;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.35;
  animation: clue-slide-in 0.3s ease-out;
}

/* Game action messages get a colored left border and subtle background */
.clue-entry.clue-type {
  border-left: 3px solid var(--hanabi-blue);
  background: rgba(98, 114, 255, 0.1);
}

.clue-entry.play-success {
  border-left: 3px solid var(--hanabi-green);
  background: rgba(80, 250, 123, 0.1);
}

.clue-entry.play-fail {
  border-left: 3px solid var(--hanabi-red);
  background: rgba(255, 85, 85, 0.12);
}

.clue-entry.discard-type {
  border-left: 3px solid var(--hanabi-yellow);
  background: rgba(241, 250, 140, 0.08);
}

.clue-entry .clue-giver {
  font-weight: 700;
  color: var(--skills-accent);
}

.clue-entry .clue-target {
  font-weight: 700;
  color: var(--hanabi-blue);
}

.clue-entry .clue-arrow {
  opacity: 0.5;
  margin: 0 0.2rem;
}

.clue-entry .clue-detail {
  font-weight: 600;
}

.clue-feed-empty {
  text-align: center;
  color: var(--skills-text-dim);
  font-style: italic;
  padding: 1rem 0;
  font-size: 0.85rem;
}

@keyframes clue-slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Other Players' Hands ===== */
#other-players {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 0.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.player-hand-row {
  margin-bottom: 0.6rem;
  background: var(--skills-surface);
  border-radius: var(--skills-radius);
  padding: 0.5rem;
  border: 1px solid var(--skills-border);
  transition: border-color 0.3s;
}

.player-hand-row.active-turn {
  border-color: var(--skills-success);
  box-shadow: 0 0 8px rgba(0, 204, 136, 0.2);
}

.player-hand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.player-hand-name {
  font-weight: 700;
  font-size: 0.9rem;
}

.player-hand-name .turn-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--skills-success);
  margin-right: 0.35rem;
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.clue-btn {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--skills-primary);
  color: var(--skills-text);
  border: 1px solid var(--skills-border);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.clue-btn:active {
  transform: scale(0.95);
}

.clue-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.clue-btn.can-clue {
  background: var(--hanabi-blue);
  color: #fff;
  border-color: var(--hanabi-blue);
}

.player-cards {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
  overflow-x: auto;
}

/* ===== Card Styling (shared for face-up & face-down) ===== */
.hanabi-card {
  width: 52px;
  min-width: 52px;
  height: 72px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.3rem;
  border: 2px solid rgba(255,255,255,0.15);
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
  cursor: default;
  user-select: none;
}

.hanabi-card .card-number {
  font-size: 1.4rem;
  line-height: 1;
}

.hanabi-card .card-color-dot {
  font-size: 0.65rem;
  margin-top: 2px;
}

/* Face-up card colors */
.hanabi-card.color-red { background: var(--hanabi-red); color: #1a1a2e; }
.hanabi-card.color-blue { background: var(--hanabi-blue); color: #fff; }
.hanabi-card.color-green { background: var(--hanabi-green); color: #1a1a2e; }
.hanabi-card.color-yellow { background: var(--hanabi-yellow); color: #1a1a2e; }
.hanabi-card.color-white { background: var(--hanabi-white); color: #1a1a2e; }

/* Highlighted card (during clue) */
.hanabi-card.clue-highlight {
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
  transform: scale(1.08);
  z-index: 2;
}

/* ===== My Hand (hidden cards at bottom) ===== */
#my-hand-section {
  background: var(--skills-surface);
  border-top: 2px solid var(--skills-border);
  padding: 0.5rem;
  flex-shrink: 0;
}

#my-hand-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

#my-hand-label .hand-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--skills-text-dim);
}

#my-hand-label .turn-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  background: var(--skills-success);
  color: #1a1a2e;
  animation: pulse-go 1.5s infinite;
}

@keyframes pulse-go {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

#my-cards {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

/* Face-down (my) cards */
.hanabi-card.face-down {
  background: var(--skills-primary);
  border: 2px solid var(--skills-border);
  cursor: pointer;
  min-height: 82px;
  width: 58px;
  min-width: 58px;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  font-size: 0.65rem;
}

.hanabi-card.face-down:active {
  transform: scale(0.95);
}

.hanabi-card.face-down.my-turn {
  border-color: var(--skills-success);
  cursor: pointer;
}

.hanabi-card.face-down.my-turn:hover {
  background: rgba(0, 204, 136, 0.15);
}

.card-clue-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 0.65rem;
  line-height: 1.2;
  text-align: center;
}

.card-clue-info .known {
  font-weight: 700;
  font-size: 0.8rem;
}

.card-clue-info .negative {
  opacity: 0.5;
  font-size: 0.55rem;
}

.card-slot-number {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.55rem;
  opacity: 0.4;
}

/* ===== Clue Modal ===== */
.clue-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.clue-modal {
  background: var(--skills-surface);
  border-radius: var(--skills-radius-lg);
  border: 1px solid var(--skills-border);
  padding: 1.25rem;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
}

.clue-modal h3 {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.clue-modal .target-cards {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.clue-buttons-section {
  margin-bottom: 0.75rem;
}

.clue-buttons-section h4 {
  font-size: 0.8rem;
  color: var(--skills-text-dim);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.clue-option-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.clue-option-btn {
  min-width: 48px;
  height: 44px;
  border-radius: 6px;
  border: 2px solid var(--skills-border);
  background: var(--skills-primary);
  color: var(--skills-text);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.clue-option-btn:active {
  transform: scale(0.95);
}

.clue-option-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.clue-option-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

/* Color buttons get their color background */
.clue-option-btn.color-red { background: var(--hanabi-red); color: #1a1a2e; }
.clue-option-btn.color-blue { background: var(--hanabi-blue); color: #fff; }
.clue-option-btn.color-green { background: var(--hanabi-green); color: #1a1a2e; }
.clue-option-btn.color-yellow { background: var(--hanabi-yellow); color: #1a1a2e; }
.clue-option-btn.color-white { background: var(--hanabi-white); color: #1a1a2e; }

.clue-modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.clue-modal-actions button {
  flex: 1;
  padding: 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.clue-modal-actions button:active {
  opacity: 0.8;
}

.btn-give-clue {
  background: var(--skills-success);
  color: #1a1a2e;
}

.btn-give-clue:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-clue-cancel {
  background: var(--skills-border);
  color: var(--skills-text);
}

/* ===== Play/Discard Modal ===== */
.action-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.action-modal {
  background: var(--skills-surface);
  border-radius: var(--skills-radius-lg);
  border: 1px solid var(--skills-border);
  padding: 1.25rem;
  width: 100%;
  max-width: 320px;
  text-align: center;
}

.action-modal h3 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.action-modal .card-knowledge {
  background: var(--skills-primary);
  border-radius: var(--skills-radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.5;
}

.action-modal .card-knowledge .known-line {
  font-weight: 700;
}

.action-modal-buttons {
  display: flex;
  gap: 0.5rem;
}

.action-modal-buttons button {
  flex: 1;
  padding: 0.7rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: transform 0.1s;
}

.action-modal-buttons button:active {
  transform: scale(0.95);
}

.btn-play-card {
  background: var(--hanabi-green);
  color: #1a1a2e;
}

.btn-discard-card {
  background: var(--hanabi-yellow);
  color: #1a1a2e;
}

.btn-discard-card:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-action-cancel {
  background: var(--skills-border);
  color: var(--skills-text);
  flex: 0.6;
}

/* ===== Announcement Modal ===== */
#announce-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}

#announce-modal .modal-content {
  background: var(--skills-surface);
  border-radius: var(--skills-radius-lg);
  border: 1px solid var(--skills-border);
  padding: 2rem 1.5rem;
  text-align: center;
  max-width: 340px;
  width: 100%;
}

.announce-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

#announce-modal h2 {
  margin-bottom: 0.5rem;
}

#announce-modal p {
  color: var(--skills-text-dim);
  margin-bottom: 1rem;
  line-height: 1.5;
  white-space: pre-line;
}

#announce-modal .btn {
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  background: var(--skills-success);
  color: #1a1a2e;
  font-size: 0.9rem;
}

/* ===== Discard Pile Drawer ===== */
#discard-drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: var(--skills-surface);
  border-top: 2px solid var(--skills-border);
  border-radius: var(--skills-radius-lg) var(--skills-radius-lg) 0 0;
  padding: 1rem;
  z-index: 900;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

#discard-drawer.open {
  transform: translateY(0);
}

#discard-drawer h3 {
  text-align: center;
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.discard-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  justify-content: center;
}

.discard-grid .hanabi-card {
  width: 40px;
  min-width: 40px;
  height: 56px;
  font-size: 1rem;
}

.discard-close {
  display: block;
  margin: 0.75rem auto 0;
  padding: 0.4rem 1.5rem;
  border-radius: 6px;
  background: var(--skills-border);
  color: var(--skills-text);
  border: none;
  font-weight: 600;
  cursor: pointer;
}

/* ===== How to Play Modal ===== */
#howtoplay-modal {
  position: fixed;
  inset: 0;
  background: #282A36;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#howtoplay-modal .modal-content {
  position: relative;
  padding: 1.5rem 1.25rem 2rem;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

#howtoplay-modal .howto-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: color 0.15s;
}

#howtoplay-modal .howto-close:hover {
  color: #fff;
}

#howtoplay-modal h2 {
  text-align: center;
  margin-bottom: 0.5rem;
  color: #50FA7B;
  font-size: 1.75rem;
  font-weight: 800;
}

#howtoplay-modal h3 {
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: #50FA7B;
  font-size: 1.35rem;
}

#howtoplay-modal p {
  font-size: 1.25rem;
  line-height: 1.7;
  color: #e0e0e0;
  margin-bottom: 0.6rem;
}

#howtoplay-modal li {
  font-size: 1.2rem;
  line-height: 1.7;
  color: #e0e0e0;
  margin-bottom: 0.4rem;
}

#howtoplay-modal strong {
  color: #fff;
}

#howtoplay-modal em {
  color: #FFB86C;
}

#howtoplay-modal ul {
  padding-left: 1.2rem;
}

#howtoplay-modal .btn-close-howto {
  display: block;
  margin: 2rem auto 0;
  padding: 0.7rem 2rem;
  border-radius: 6px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  background: var(--skills-success);
  color: #1a1a2e;
  font-size: 1rem;
}

/* ===== Utility ===== */
.hidden {
  display: none !important;
}

/* ===== Tablet/Desktop Enhancements ===== */
@media (min-width: 600px) {
  .hanabi-card {
    width: 60px;
    min-width: 60px;
    height: 82px;
    font-size: 1.5rem;
  }

  .hanabi-card.face-down {
    width: 66px;
    min-width: 66px;
    min-height: 92px;
  }

  .hanabi-card .card-number {
    font-size: 1.6rem;
  }

  #clue-feed {
    max-height: 32vh;
  }

  .clue-entry {
    font-size: 1rem;
  }

  .player-hand-name {
    font-size: 1rem;
  }

  .firework-pile .pile-value {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  #howtoplay-modal h2 { font-size: 1.625rem; }
  #howtoplay-modal h3 { font-size: 1.225rem; }
  #howtoplay-modal p { font-size: 1.125rem; }
  #howtoplay-modal li { font-size: 1.075rem; }
}
