:root {
  --bg-color: #f4f4f9;
  --board-bg: #cde6d0;
  --text-primary: #111;
  --panel-bg: #fff;
  --border-color: #333;
  --primary-color: #e53935;
  --secondary-color: #1e88e5;
  --hover-color: #ef5350;
}

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

body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
}

.game-container {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1200px;
  padding: 20px;
}

/* ──────────────────────────────────────────
   Board Layout
────────────────────────────────────────── */
.board-wrapper {
  background-color: var(--board-bg);
  border: 3px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
  /* On desktop: shrink-wrap the board */
  flex-shrink: 0;
}

.board {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  width: 760px;
  height: 760px;
  gap: 2px;
  background-color: var(--border-color);
}

/* Base style for all board spaces */
.space {
  background-color: #fafaf8;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.space.corner {
  justify-content: center;
  align-items: center;
}

.space-name {
  font-size: 10px;
  font-weight: bold;
  font-family: 'Oswald', sans-serif;
  padding: 0 2px;
  word-wrap: break-word;
  line-height: 1.1;
  margin-top: 5px;
  flex-grow: 1;
}

.space-price {
  font-size: 9px;
  font-weight: bold;
  margin-bottom: 5px;
}

.color-bar {
  height: 20%;
  width: 100%;
  border-bottom: 2px solid var(--border-color);
}

/* Bottom row faces up */
.space.bottom-row {
  justify-content: space-between;
}

/* Top row faces down */
.space.top-row {
  flex-direction: column-reverse;
}
.space.top-row .color-bar {
  border-bottom: none;
  border-top: 2px solid var(--border-color);
}

/* Left column faces right */
.space.left-col {
  flex-direction: row-reverse;
}
.space.left-col .color-bar {
  height: 100%;
  width: 20%;
  border-bottom: none;
  border-left: 2px solid var(--border-color);
}
.space.left-col .space-name, .space.left-col .space-price {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

/* Right column faces left */
.space.right-col {
  flex-direction: row;
}
.space.right-col .color-bar {
  height: 100%;
  width: 20%;
  border-bottom: none;
  border-right: 2px solid var(--border-color);
}
.space.right-col .space-name, .space.right-col .space-price {
  writing-mode: vertical-rl;
}

/* Center Area */
.center-area {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  background-color: var(--board-bg);
  display: flex;
  justify-content: center;
  align-items: center;
  border: 2px solid var(--border-color);
}

.logo-text {
  font-family: 'Oswald', sans-serif;
  font-size: 5rem;
  color: white;
  background: red;
  padding: 10px 30px;
  border: 4px solid white;
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  transform: rotate(-35deg);
  letter-spacing: 5px;
  text-shadow: 2px 2px 0 #000;
}

/* ──────────────────────────────────────────
   Sidebar Panels
────────────────────────────────────────── */
.sidebar {
  display: flex;
  flex-direction: column;
  row-gap: 20px;
  width: 350px;
  flex-shrink: 0;
}

.panel {
  background-color: var(--panel-bg);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.1);
}

.panel h2 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 15px;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 5px;
  color: var(--text-primary);
}

/* ──────────────────────────────────────────
   Buttons
────────────────────────────────────────── */
.btn {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Roboto', sans-serif;
  min-height: 44px; /* Accessible touch target */
}

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

.btn.primary {
  background-color: var(--primary-color);
  color: white;
}
.btn.primary:hover:not(:disabled) {
  background-color: var(--hover-color);
  transform: translateY(-2px);
}

.btn.secondary {
  background-color: var(--secondary-color);
  color: white;
}
.btn.secondary:hover:not(:disabled) {
  background-color: #1565c0;
  transform: translateY(-2px);
}

/* ──────────────────────────────────────────
   Action Log
────────────────────────────────────────── */
.action-log ul {
  list-style: none;
  max-height: 250px;
  overflow-y: auto;
}

.action-log li {
  padding: 8px 0;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

/* ──────────────────────────────────────────
   Modal
────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(3px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  padding: 16px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: white;
  padding: 30px;
  border-radius: 12px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  text-align: center;
}

.modal h3 {
  font-family: 'Oswald', sans-serif;
  font-size: 24px;
  margin-bottom: 10px;
}

.modal p {
  margin-bottom: 20px;
  color: #555;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

/* ──────────────────────────────────────────
   Tokens
────────────────────────────────────────── */
.tokens {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 80%;
  justify-content: center;
  pointer-events: none;
}

.token {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 10;
  transition: all 0.3s ease;
}

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.dice-result {
  text-align: center;
  font-weight: bold;
  font-size: 1.2rem;
  margin-bottom: 10px;
  min-height: 24px;
  color: var(--secondary-color);
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */

/* Tablet: stack vertically */
@media (max-width: 900px) {
  .game-container {
    flex-direction: column;
    align-items: center;
    padding: 12px;
    gap: 16px;
  }
  .sidebar {
    width: 100%;
    max-width: 760px;
  }
}

/* Mobile: scale board to fit screen */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
    overflow-x: hidden;
  }

  .game-container {
    flex-direction: column;
    align-items: center;
    padding: 8px;
    gap: 12px;
    width: 100vw;
    overflow-x: hidden;
  }

  /* Board wrapper: exact square, clips the scaled board */
  .board-wrapper {
    padding: 0;
    border-width: 2px;
    border-radius: 8px;
    overflow: hidden;
    width: calc(100vw - 16px);
    height: calc(100vw - 16px);
    display: block;
    position: relative;
    flex-shrink: 0;
  }

  /* board-scale-wrapper fills the wrapper */
  .board-scale-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
  }

  /* Scale 760px board to fit available width */
  .board {
    position: absolute;
    top: 0;
    left: 0;
    width: 760px;
    height: 760px;
    transform-origin: top left;
    transform: scale(calc((100vw - 20px) / 760));
  }

  /* Sidebar: full width */
  .sidebar {
    width: 100%;
  }

  /* Bigger touch targets */
  .btn {
    min-height: 48px;
    font-size: 16px;
    padding: 14px 12px;
  }

  /* Readable panel text */
  .panel h2 {
    font-size: 1.1rem;
  }
  .action-log li {
    font-size: 13px;
  }

  /* Modal: bottom sheet */
  .modal-overlay {
    align-items: flex-end;
  }
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    padding: 24px 20px;
  }
}

/* Extra small: hide board text */
@media (max-width: 400px) {
  .space-name, .space-price {
    display: none;
  }
}
