/**
 * public/css/korki.css
 * V5.0 Professional Bilingual Design System for KORKI (ቆርኪ ዳማ 3D)
 */
:root {
  --bg-top: #26140B;
  --bg-mid: #1A0D07;
  --bg-bot: #100703;
  --card-bg: #2B170D;
  --card-border: rgba(229, 169, 60, 0.32);
  --gold: #E5A93C;
  --gold-bright: #FFD54F;
  --green: #1E8E3E;
  --green-bright: #69F0AE;
  --red: #D93025;
  --text-main: #FFF3E0;
  --text-sub: #D7CCC8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Ethiopic", sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bot) 100%);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: 70px;
}

.tibeb-bar {
  height: 4px;
  background: linear-gradient(90deg, #009A44 0%, #FCD116 50%, #EF3340 100%);
  width: 100%;
}

/* Splash Screen Overlay */
#splash-screen {
  position: fixed;
  inset: 0;
  z-index: 950;
  background: radial-gradient(circle at 50% 38%, #3E2111 0%, #1E0F07 60%, #100703 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.4s ease;
}
#splash-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* First-Time Language Onboarding Modal */
#lang-onboarding-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(10, 5, 2, 0.88);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#lang-onboarding-modal.open {
  display: flex;
}
.lang-modal-card {
  background: linear-gradient(160deg, #3A2012 0%, #1E1008 100%);
  border: 2px solid var(--gold);
  border-radius: 24px;
  padding: 24px 20px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,0.75);
}
.lang-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}
.lang-choice-btn {
  background: #27140A;
  border: 1.5px solid var(--card-border);
  border-radius: 16px;
  padding: 16px 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.lang-choice-btn:active, .lang-choice-btn:hover {
  transform: scale(0.96);
  border-color: var(--gold-bright);
  background: rgba(229, 169, 60, 0.18);
}
.lang-choice-btn .flag {
  font-size: 28px;
  display: block;
  margin-bottom: 6px;
}
.lang-choice-btn .lname {
  font-size: 15px;
  font-weight: 900;
  display: block;
}
.lang-choice-btn .lsub {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--gold-bright);
  margin-top: 3px;
  display: block;
}

.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 12px 20px;
}

/* Compact Header Bar */
.top-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
}
.logo-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid var(--gold);
  background: url('/korki_logo.png') center/cover no-repeat, radial-gradient(circle at 35% 35%, #FFE082, #B26A00);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  flex-shrink: 0;
}
.title-group {
  flex: 1;
  min-width: 0;
}
.title-group h1 {
  font-size: 16.5px;
  font-weight: 900;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.title-group p {
  font-size: 11px;
  color: var(--gold-bright);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-pill {
  background: #221209;
  border: 1px solid var(--gold);
  border-radius: 14px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

/* Segmented am | EN Language Switcher */
.lang-switch-seg {
  display: inline-flex;
  align-items: center;
  background: #1B0E07;
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  height: 34px;
}
.lang-switch-seg.compact {
  height: 32px;
}
.lang-switch-seg .seg-item {
  font-size: 11px;
  font-weight: 900;
  padding: 4px 6px;
  border-radius: 7px;
  color: var(--text-sub);
  transition: all 0.15s ease;
}
.lang-switch-seg .seg-item.active {
  background: var(--gold-bright);
  color: #1F0F05;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: #361F12;
  color: var(--gold-bright);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn.sm {
  width: 32px;
  height: 32px;
  font-size: 14px;
}
.icon-btn:active, .pro-back-btn:active, .lang-switch-seg:active {
  transform: scale(0.93);
}

/* Sleek Professional Top Bar in Game View (Requirement 4) */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  background: rgba(34, 18, 9, 0.78);
  border: 1px solid rgba(229, 169, 60, 0.25);
  border-radius: 14px;
  padding: 6px 8px;
  backdrop-filter: blur(8px);
}
.pro-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 11px 0 8px;
  border-radius: 10px;
  border: 1px solid rgba(229, 169, 60, 0.45);
  background: linear-gradient(135deg, #3D2112 0%, #26130A 100%);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.game-title-pill {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-top-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* Hero Quick Match Card */
.hero-card {
  background: linear-gradient(135deg, #3E2212 0%, #241208 100%);
  border: 1.5px solid var(--gold-bright);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.hero-title {
  font-size: 16px;
  font-weight: 900;
  color: #FFF3E0;
}
.hero-sub {
  font-size: 11.5px;
  color: var(--text-sub);
  margin-top: 2px;
}

.online-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  background: rgba(30, 142, 62, 0.25);
  border: 1px solid #25A84B;
  color: var(--green-bright);
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 800;
}

/* 2x2 Bento Action Grid */
.bento-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 10px;
}
.bento-tile {
  background: linear-gradient(145deg, #331C10 0%, #221209 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 13px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.bento-tile:active {
  transform: scale(0.96);
  border-color: var(--gold-bright);
}
.bento-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.bento-text {
  min-width: 0;
}
.bento-text h3 {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bento-text p {
  font-size: 11px;
  color: var(--text-sub);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card {
  background: linear-gradient(145deg, #331C10 0%, #221209 100%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 12px 13px;
  margin-bottom: 10px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.card-title {
  font-size: 13.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar {
  display: none;
}
.chip {
  padding: 6px 11px;
  border-radius: 18px;
  background: #180C06;
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text-sub);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.chip.active {
  background: rgba(229, 169, 60, 0.28);
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  font-weight: 800;
}

.btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.12s ease;
}
.btn:active {
  transform: scale(0.97);
}
.btn-gold {
  background: linear-gradient(135deg, #FFD54F 0%, #E5A93C 100%);
  color: #1F0F05;
}
.btn-green {
  background: linear-gradient(135deg, #25A84B 0%, #177531 100%);
  color: #FFFFFF;
}
.btn-brown {
  background: #422616;
  color: var(--text-main);
  border: 1px solid var(--card-border);
}
.btn-red {
  background: linear-gradient(135deg, #E53935 0%, #B71C1C 100%);
  color: #FFFFFF;
  border: 1.5px solid var(--gold-bright);
}

.input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.text-input {
  flex: 1;
  background: #140A05;
  border: 1px solid var(--card-border);
  border-radius: 11px;
  padding: 10px 12px;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Bottom Navigation Tabs */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: #190D06;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: space-around;
  padding: 6px 6px 9px;
}
.nav-item {
  flex: 1;
  text-align: center;
  color: var(--text-sub);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  padding: 4px 0;
  border-radius: 10px;
}
.nav-item.active {
  color: var(--gold-bright);
  background: rgba(229, 169, 60, 0.15);
}
.nav-item span {
  display: block;
  font-size: 17px;
  margin-bottom: 1px;
}

.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}

/* Game View */
#game-view {
  display: none;
}
.hud-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 7px;
}
.hud-card {
  background: #221209;
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 13px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, border-color 0.15s ease;
}
.hud-card.editable {
  cursor: pointer;
}
.hud-card.editable:active {
  transform: scale(0.97);
}
.hud-card.active {
  background: #3A2113;
  border-color: var(--gold-bright);
  box-shadow: 0 0 10px rgba(255, 213, 79, 0.22);
}
.hud-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #FFF;
  flex-shrink: 0;
}
.hud-info {
  min-width: 0;
  flex: 1;
}
.hud-name-line {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hud-info h4 {
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.edit-name-badge {
  font-size: 11px;
  color: var(--gold-bright);
  background: rgba(229, 169, 60, 0.2);
  padding: 1px 5px;
  border-radius: 6px;
  flex-shrink: 0;
}
.hud-info p {
  font-size: 10.5px;
  color: var(--text-sub);
  white-space: nowrap;
  margin-top: 1px;
}
.hud-series-pill {
  display: inline-block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 6px;
  border-radius: 6px;
}

.status-banner {
  background: rgba(229, 169, 60, 0.15);
  border: 1px solid var(--gold);
  border-radius: 11px;
  padding: 7px 11px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
}

.board-stage {
  width: 100%;
  aspect-ratio: 840 / 740;
  margin: 4px 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board-canvas {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  transition: transform 0.3s ease;
  touch-action: manipulation;
}


.action-bar {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.list-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
}

/* Modal Dialogs */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  backdrop-filter: blur(6px);
  z-index: 920;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open {
  display: flex;
}
.modal-box {
  background: #28160D;
  border: 1.5px solid var(--gold);
  border-radius: 20px;
  max-width: 400px;
  width: 100%;
  padding: 18px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.7);
}

/* Structured Dama Rules Modal (Requirement 5) */
.rules-modal-box {
  max-width: 410px;
}
.rules-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(229, 169, 60, 0.25);
}
.rule-card-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(20, 10, 5, 0.55);
  border: 1px solid rgba(229, 169, 60, 0.22);
  border-radius: 14px;
  padding: 10px 12px;
  margin-bottom: 9px;
}
.rule-num-badge {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(229, 169, 60, 0.25);
  border: 1px solid var(--gold-bright);
  color: var(--gold-bright);
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.rule-card-item h4 {
  font-size: 13px;
  font-weight: 800;
  color: #FFF3E0;
  margin-bottom: 3px;
}
.rule-card-item p {
  font-size: 11.8px;
  line-height: 1.42;
  color: var(--text-sub);
}

/* Dramatic Post-Game Victory / Defeat Overlay Modal (Requirements 7 & 8) */
.gameover-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, #381E10 0%, #1B0D06 100%);
  border: 2px solid var(--gold-bright);
  border-radius: 24px;
  max-width: 390px;
  width: 100%;
  padding: 22px 18px 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.85);
  animation: popInCard 0.32s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.gameover-card.defeat-theme {
  background: linear-gradient(160deg, #2D1212 0%, #160808 100%);
  border-color: #EF5350;
}
@keyframes popInCard {
  0% { transform: scale(0.82); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.gameover-main-emoji {
  font-size: 64px;
  line-height: 1.1;
  margin-bottom: 8px;
  display: inline-block;
  animation: emojiPulseBounce 1.2s infinite ease-in-out;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.5));
}
@keyframes emojiPulseBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.12); }
}
.emoji-burst-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.burst-particle {
  position: absolute;
  font-size: 20px;
  opacity: 0;
  animation: floatUpParticle 2.2s infinite ease-out;
}
@keyframes floatUpParticle {
  0% { transform: translateY(40px) scale(0.6); opacity: 0; }
  30% { opacity: 0.95; }
  100% { transform: translateY(-90px) scale(1.15); opacity: 0; }
}
.gameover-headline {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 4px;
}
.gameover-card.defeat-theme .gameover-headline {
  color: #FF8A80;
}
.gameover-subtitle {
  font-size: 12.5px;
  color: var(--text-sub);
  font-weight: 700;
  margin-bottom: 14px;
}
.gameover-score-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.score-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.score-name {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-val {
  font-size: 14px;
  font-weight: 900;
  color: #FFF3E0;
}
.score-vs {
  font-size: 11px;
  font-weight: 900;
  color: var(--gold-bright);
  padding: 0 10px;
}
.next-starter-pill {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--green-bright);
  background: rgba(30, 142, 62, 0.2);
  border: 1px solid rgba(105, 240, 174, 0.35);
  border-radius: 10px;
  padding: 6px 10px;
  margin-bottom: 12px;
}
.rematch-countdown-box {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.rematch-timer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.countdown-badge {
  color: var(--gold-bright);
  font-size: 13px;
  font-weight: 900;
}
.rematch-bar-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
}
.rematch-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #69F0AE, #FFD54F, #FF5252);
  transition: width 0.2s linear;
}
.gameover-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
