/* dominoes-style.css */
@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;600;700;900&display=swap');

:root {
  --bg:         var(--world-bg, #0d0d0f);
  --bg2:        var(--world-bg-2, #17171a);
  --gold:       var(--world-accent, #b9f36b);
  --gold2:      var(--world-accent-2, #d7ff9b);
  --text:       var(--world-text, #f5f5f5);
  --text-dim:   var(--world-muted, #a6a6ad);
  --radius:     12px;
  --font-main:  'Heebo', 'Segoe UI', 'Arial', sans-serif;
  --board-bg:   linear-gradient(160deg, var(--world-panel-strong, #20262a), var(--world-bg-2, #17171a));
  --board-border: var(--world-accent, #b9f36b);
  --tile-bg:    #fdfbf7;
  --tile-color: #182019;
  --tile-shadow: 0 4px 6px rgba(0,0,0,0.4), inset 0 -2px 5px rgba(0,0,0,0.1);
}

[data-theme="light"] {
  --bg: var(--world-light-bg, #f7f7f4);
  --bg2: var(--world-light-bg-2, #eceee8);
  --text: #182019;
  --text-dim: #526057;
  --board-bg: linear-gradient(160deg, #ffffff, #e8eee5);
  --board-border: #477a11;
  --gold: #477a11;
  --tile-bg: #fff;
  --tile-color: #2c1a0e;
  --tile-shadow: 0 3px 5px rgba(0,0,0,0.2), inset 0 -2px 3px rgba(0,0,0,0.05);
}

[data-theme="navy-gold"] {
  --bg: #0f172a;
  --bg2: #1e293b;
  --text: #f8fafc;
  --text-dim: #cbd5e1;
  --board-bg: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  --board-border: #d9a441;
  --gold: #d9a441;
  --tile-bg: #e2e8f0;
  --tile-color: #0f172a;
  --tile-shadow: 0 4px 8px rgba(0,0,0,0.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  /* No `direction: rtl` here: an author rule on html/body outranks the [dir]
     attribute the language switcher sets, so English stayed RTL no matter what
     the player picked. Direction now follows <html dir>, which the game sets. */
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer; border: none; font-family: inherit; font-size: inherit;
  transition: transform .12s, filter .12s; touch-action: manipulation;
}
button:active { transform: scale(0.94); }

.dominoes-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--world-panel, rgba(18,20,24,.82));
  border-bottom: 1px solid var(--world-line, rgba(185,243,107,.18));
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
}
.back-btn {
  color: var(--gold); text-decoration: none; font-size: 0.9rem; font-weight: 600;
  padding: 6px 12px; border: 1px solid var(--world-line, rgba(185,243,107,.28)); border-radius: 8px;
  transition: background 0.2s;
}
.back-btn:hover { background: rgba(185,243,107,0.15); }
.dominoes-brand { font-size: 1.1rem; font-weight: 900; color: var(--gold); text-shadow: 0 0 15px rgba(185,243,107,0.5); }

/* SCREENS */
.screen {
  display: none; position: fixed; top: 44px; bottom: 0; left: 0; right: 0;
  align-items: center; justify-content: center; flex-direction: column;
  background: radial-gradient(ellipse at 50% 30%, var(--bg2) 0%, var(--bg) 65%);
  overflow: auto; padding: 16px;
}
.screen.active { display: flex; }

/* MENU */
.menu-logo { font-size: clamp(2rem,8vw,3.5rem); font-weight: 900; color: var(--gold); margin-bottom: 4px; }
.menu-sub { font-size: .9rem; color: var(--text-dim); letter-spacing: .15em; text-transform: uppercase; margin-bottom: 40px; }
.menu-btns { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; }
.btn-primary {
  padding: 16px 24px; border-radius: var(--radius); font-size: clamp(.95rem,3.5vw,1.1rem); font-weight: 700;
  background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #0d0d0f;
  box-shadow: 0 4px 16px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.15) inset;
}
.btn-secondary {
  padding: 14px 24px; border-radius: var(--radius); font-size: clamp(.88rem,3vw,1rem); font-weight: 600;
  background: rgba(128,128,128,.1); color: var(--text); border: 1px solid rgba(128,128,128,.3);
}
.menu-footer { margin-top: 28px; display: flex; gap: 12px; }
.btn-icon {
  padding: 8px 14px; border-radius: 8px; background: rgba(128,128,128,.1);
  color: var(--text); font-size: 1rem; border: 1px solid rgba(128,128,128,.2);
}

/* DIFFICULTY */
.diff-title { font-size: clamp(1.2rem,5vw,1.8rem); font-weight: 800; color: var(--gold); margin-bottom: 28px; }
.diff-btns { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 300px; }

/* GAME TOPBAR */
#screen-game { justify-content: flex-start; padding: 8px; overflow: hidden; }
.game-topbar, .game-bottombar {
  width: 100%; max-width: 1000px; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 8px; margin-bottom: 10px;
}
.game-bottombar { margin-top: 10px; margin-bottom: 0; }
.score-panel {
  display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,.15);
  padding: 6px 12px; border-radius: 8px;
}
.score-panel.mine { box-shadow: 0 0 0 2px var(--gold); }
.score-num { font-size: 1.1rem; font-weight: 700; color: var(--text); min-width: 18px; text-align: center; }
#status-text { flex: 1; text-align: center; font-size: clamp(.85rem,2.5vw,1rem); font-weight: 700; color: var(--text); }
.btn-topbar { padding: 5px 10px; border-radius: 6px; background: rgba(128,128,128,.1); color: var(--text-dim); border: 1px solid rgba(128,128,128,.2); }

.action-btns { display: flex; gap: 10px; justify-content: center; flex: 1; }
.btn-action {
  padding: 8px 16px; border-radius: 8px; font-weight: 700;
  background: var(--gold); color: #0d0d0f;
}
.btn-action:disabled { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; }
.boneyard-info { font-size: 0.9rem; font-weight: 600; color: var(--text-dim); }

/* BOARD */
.board-wrap { display: flex; justify-content: center; align-items: center; flex: 1; width: 100%; min-height: 200px; overflow: hidden; }
.board-frame {
  background: var(--board-bg);
  padding: 20px;
  border-radius: 12px;
  box-shadow: inset 0 0 0 4px var(--board-border), 0 10px 30px rgba(0,0,0,.5);
  width: 100%; height: 100%;
  overflow-x: auto; overflow-y: hidden;
  display: flex; align-items: center;
  position: relative;
  scrollbar-width: thin;
}
#domino-chain {
  display: flex; align-items: center; justify-content: center;
  min-width: min-content; margin: 0 auto; gap: 2px;
  padding: 20px;
}

/* HAND */
#player-hand {
  width: 100%; max-width: 1000px; height: 120px;
  display: flex; gap: 8px; align-items: center; justify-content: center;
  overflow-x: auto; padding: 10px;
  scrollbar-width: none;
}

/* TILE */
.domino-tile {
  background: var(--tile-bg); color: var(--tile-color);
  border-radius: 6px; position: relative;
  box-shadow: var(--tile-shadow);
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
  flex: none;
}
/* Vertical tile (in hand, or doubles in chain) */
.domino-tile.vertical {
  width: 40px; height: 80px;
}
/* Horizontal tile (in chain) */
.domino-tile.horizontal {
  width: 80px; height: 40px; flex-direction: row;
}

.domino-tile::after {
  content: ''; position: absolute; background: rgba(0,0,0,0.2);
}
.domino-tile.vertical::after { top: 50%; left: 10%; right: 10%; height: 2px; transform: translateY(-50%); }
.domino-tile.horizontal::after { left: 50%; top: 10%; bottom: 10%; width: 2px; transform: translateX(-50%); }

.domino-half {
  flex: 1; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 4px;
}
.pip {
  background: var(--tile-color); border-radius: 50%;
  width: 6px; height: 6px; place-self: center;
}

/* Hand Interaction */
#player-hand .domino-tile { cursor: pointer; }
#player-hand .domino-tile:hover { transform: translateY(-10px); }
#player-hand .domino-tile.selected {
  box-shadow: 0 0 0 3px var(--gold), 0 10px 20px rgba(0,0,0,0.5);
  transform: translateY(-15px); z-index: 10;
}

/* Chain drop zones */
.drop-zone {
  width: 40px; height: 80px; border: 2px dashed rgba(255,255,255,0.2); border-radius: 6px;
  display: none; cursor: pointer; transition: all 0.2s;
  align-items: center; justify-content: center;
}
.drop-zone.active {
  display: flex; animation: pulse-dz 1s infinite alternate;
  border-color: #4ade80; background: rgba(74,222,128,0.1);
}
.drop-zone:hover { background: rgba(74,222,128,0.3); }

@keyframes pulse-dz {
  from { box-shadow: 0 0 5px rgba(74,222,128,0.2); }
  to { box-shadow: 0 0 15px rgba(74,222,128,0.8); }
}

/* ANIMATIONS */
@keyframes slide-in-left { from { transform: translateX(-50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-in-right { from { transform: translateX(50px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.slide-in-l { animation: slide-in-left 0.3s ease-out; }
.slide-in-r { animation: slide-in-right 0.3s ease-out; }

/* WIN SCREEN */
#screen-win { text-align: center; z-index: 100; }
#win-emoji { font-size: clamp(4rem,15vw,7rem); margin-bottom: 16px; filter: drop-shadow(0 4px 16px rgba(0,0,0,.5)); }
#win-msg { font-size: clamp(1.6rem,7vw,2.8rem); font-weight: 900; color: var(--gold); margin-bottom: 40px; }
.win-btns { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 280px; margin: 0 auto; }
