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

body {
  font-family: "Arial", sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  overflow: hidden;
  /* Optimized for HD Vertical TV (1080x1920) */
}

/* Vertical TV HD Optimization (1080x1920) */
@media (min-width: 1080px) and (orientation: portrait) {
  .board {
    width: 90%;
    max-width: 1000px;
    aspect-ratio: 0.85;
  }

  .game-controls {
    bottom: 5%;
  }

  .tile.corner {
    width: 7%;
    height: 10%;
  }

  .tile.side {
    width: 7%;
    height: 7.8%;
  }

  .pawn {
    width: 60px;
    height: 60px;
  }
}

/* Screen Management */
.screen {
  display: none;
  width: 100%;
  height: 100vh;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Menu Screen */
#menu-screen {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  position: relative;
}

.menu-board-container {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.3;
}

.menu-board {
  width: 85%;
  max-width: 900px;
  aspect-ratio: 0.85;
  position: relative;
}

#menu-board-tiles .tile {
  position: absolute;
  width: 7%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
}

#menu-board-tiles .tile.corner {
  height: 10%;
}

#menu-board-tiles .tile.side {
  height: 7.8%;
}

.menu-overlay {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.menu-container {
  text-align: center;
  padding: 50px 60px;
  background: rgba(25, 60, 130, 0.95);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
}

.menu-container h1 {
  font-size: 48px;
  color: white;
  margin-bottom: 15px;
  text-transform: uppercase;
  font-weight: bold;
}

.menu-subtitle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  margin-bottom: 40px;
}

.start-btn {
  padding: 20px 80px;
  font-size: 24px;
  font-weight: bold;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  color: #1e3c72;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 20px;
  text-transform: uppercase;
}

.start-btn:hover:not(:disabled) {
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(255, 255, 255, 0.3);
}

.start-btn:disabled {
  background: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.5);
  cursor: not-allowed;
}

.name-input {
  padding: 15px 30px;
  font-size: 24px;
  font-weight: bold;
  border: 3px solid rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 30px;
  text-transform: uppercase;
  text-align: center;
  width: 400px;
  max-width: 80%;
}

.name-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
  text-transform: none;
}

.name-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.admin-link {
  display: block;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  margin-top: 15px;
}

.admin-link:hover {
  color: white;
}

/* Game Board Screen */
#game-screen {
  background: linear-gradient(135deg, #89cff0 0%, #4a90e2 100%);
  background-size: cover;
  background-position: center;
  padding: 20px;
}

.game-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.board {
  width: 100%;
  max-width: 1200px;
  aspect-ratio: 0.85;
  background: transparent;
  position: relative;
  /* border-radius: 10px; */
  /* box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3); */
  /* border: 8px solid #333; */
  overflow: hidden;
}

/* Board Tiles */
.tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: white;
  /* border: 2px solid #333; */
  border-radius: 4px;
  text-align: center;
  font-size: 10px;
  font-weight: bold;
  padding: 4px 2px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  z-index: 1;
}

/* Corner tiles - 145 × 217 (ratio 0.67:1) */
.tile.corner {
  width: 7%;
  height: 10%;
}

/* Side tiles - 145 × 161 (ratio 0.90:1) */
.tile.side {
  width: 7%;
  height: 7.8%;
}

.tile:hover {
  transform: scale(1.05);
  z-index: 2;
}

.tile-icon {
  font-size: 18px;
  margin-bottom: 2px;
}

.tile-name {
  font-size: 8px;
  line-height: 1.1;
  word-wrap: break-word;
  max-width: 100%;
  overflow: hidden;
  display: none;
}

/* Tile types styling */
.tile.START {
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.tile.FINISH {
  background: linear-gradient(135deg, #00bcd4 0%, #0097a7 100%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.tile.SINGAPORE {
  background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
  color: white;
}

.tile.THAILAND {
  background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
  color: white;
}

.tile.JAPAN {
  background: linear-gradient(135deg, #f38181 0%, #e71d36 100%);
  color: white;
}

.tile.KOREA {
  background: linear-gradient(135deg, #c44569 0%, #a73d62 100%);
  color: white;
}

.tile.MALAYSIA {
  background: linear-gradient(135deg, #6c5ce7 0%, #5f27cd 100%);
  color: white;
}

.tile.CHINA {
  background: linear-gradient(135deg, #fd79a8 0%, #e84393 100%);
  color: white;
}

.tile.AMBIL_KARTU {
  background: linear-gradient(135deg, #74b9ff 0%, #0984e3 100%);
  color: white;
}

.tile.PENALTY {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
  color: white;
}

/* Active tile highlight */
.tile.active {
  border: 3px solid #ffd700;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.6);
  transform: scale(1.1);
  z-index: 3;
}

/* Tile with custom image */
.tile.has-image {
  background-size: auto;
  background-position: center;
  background-repeat: no-repeat;
}

.tile.has-image .tile-name {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 4px 6px;
  border-radius: 4px;
  margin-top: auto;
}

/* Pawns */
.pawn {
  position: absolute;
  width: 50px;
  height: 50px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
  transition: all 0.5s ease;
  z-index: 10;
  transform: translate(-50%, 50%); /* Center pawn on tile */
}

.pawn.player1 {
  background-image: url('../assets/player/player1.png');
  filter: drop-shadow(0 4px 8px rgba(230, 30, 31, 0.5));
}

.pawn.player2 {
  background-image: url('../assets/player/player2.png');
  filter: drop-shadow(0 4px 8px rgba(208, 172, 104, 0.5));
}

/* Center Game Controls */
.center-controls {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  z-index: 5;
  min-width: 400px;
}

/* Top Row: Card Display + Roll Dice Button */
.controls-top-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.card-display {
  width: 160px;
  height: 220px;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  border: 3px solid rgba(255, 255, 255, 0.3);
}

.card-icon {
  font-size: 80px;
  color: white;
  font-weight: bold;
  margin-bottom: 10px;
}

.card-label {
  font-size: 18px;
  color: white;
  font-weight: bold;
  text-transform: uppercase;
}

/* Bottom Row: Player Indicator (Full Width) */
.controls-bottom-row {
  width: 100%;
}

.turn-indicator {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  padding: 20px 40px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-size: 24px;
  font-weight: bold;
  /* color: #333; */
  color: white;
}

/* Admin Button Row */
.controls-admin-row {
  width: 100%;
  display: flex;
  justify-content: center;
}

.admin-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-block;
}

.admin-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: white;
  transform: translateY(-2px);
}

.player-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #E61E1F;
}

.roll-dice-btn {
  width: 160px;
  padding-top: 10px;
  padding-bottom: 10px;
  font-size: 20px;
  font-weight: bold;
  background: linear-gradient(135deg, #ff4081 0%, #e91e63 100%);
  color: white;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(255, 64, 129, 0.4);
  text-transform: uppercase;
}

.roll-dice-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 7px 20px rgba(255, 64, 129, 0.6);
}

.roll-dice-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  box-shadow: none;
}

/* 3D Dice Container */
.dice-container {
  perspective: 1000px;
  width: 100px;
  height: 100px;
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.dice-container.active {
  display: block;
}

.dice-3d {
  width: 100px;
  height: 100px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s;
}

/* Dice Faces */
.dice-face {
  position: absolute;
  width: 100px;
  height: 100px;
  background: white;
  border: 2px solid #333;
  border-radius: 10px;
  display: grid;
  padding: 10px;
  box-shadow: inset 0 5px 10px rgba(0, 0, 0, 0.1);
}

.dice-face .dot {
  width: 18px;
  height: 18px;
  background: #333;
  border-radius: 50%;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Face 1 - Front */
.dice-face-1 {
  transform: translateZ(50px);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Face 2 - Back */
.dice-face-2 {
  transform: rotateY(180deg) translateZ(50px);
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  padding: 15px;
}

.dice-face-2 .dot:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.dice-face-2 .dot:nth-child(2) {
  grid-column: 2;
  grid-row: 2;
}

/* Face 3 - Right */
.dice-face-3 {
  transform: rotateY(90deg) translateZ(50px);
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
}

.dice-face-3 .dot:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.dice-face-3 .dot:nth-child(2) {
  grid-column: 2;
  grid-row: 2;
}

.dice-face-3 .dot:nth-child(3) {
  grid-column: 3;
  grid-row: 3;
}

/* Face 4 - Left */
.dice-face-4 {
  transform: rotateY(-90deg) translateZ(50px);
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  padding: 15px;
  gap: 30px;
}

/* Face 5 - Top */
.dice-face-5 {
  transform: rotateX(90deg) translateZ(50px);
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
}

.dice-face-5 .dot:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.dice-face-5 .dot:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}

.dice-face-5 .dot:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.dice-face-5 .dot:nth-child(4) {
  grid-column: 1;
  grid-row: 3;
}

.dice-face-5 .dot:nth-child(5) {
  grid-column: 3;
  grid-row: 3;
}

/* Face 6 - Bottom */
.dice-face-6 {
  transform: rotateX(-90deg) translateZ(50px);
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 15px;
  gap: 10px;
}

/* Dice Rolling Animations */
@keyframes roll {
  0% {
    transform: rotateX(0deg) rotateY(0deg);
  }
  100% {
    transform: rotateX(720deg) rotateY(720deg);
  }
}

.dice-3d.rolling {
  animation: roll 1s ease-out;
}

/* Dice result positions */
.dice-3d.show-1 {
  transform: rotateX(0deg) rotateY(0deg);
}

.dice-3d.show-2 {
  transform: rotateX(0deg) rotateY(180deg);
}

.dice-3d.show-3 {
  transform: rotateX(0deg) rotateY(-90deg);
}

.dice-3d.show-4 {
  transform: rotateX(0deg) rotateY(90deg);
}

.dice-3d.show-5 {
  transform: rotateX(-90deg) rotateY(0deg);
}

.dice-3d.show-6 {
  transform: rotateX(90deg) rotateY(0deg);
}

/* Popups */
.popup {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.popup.active {
  display: flex;
}

.popup-content {
  background: white;
  padding: 50px;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  max-width: 800px;
  width: 85%;
  text-align: center;
}

/* Quiz Popup */
.quiz-content h2 {
  color: #333;
  margin-bottom: 25px;
  font-size: 42px;
}

.quiz-question {
  font-size: 28px;
  color: #333;
  margin-bottom: 35px;
  line-height: 1.6;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.quiz-option {
  display: flex;
  align-items: center;
  padding: 20px 25px;
  border: 4px solid #4a90e2;
  background: white;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: left;
}

.quiz-option:hover {
  background: #4a90e2;
  color: white;
  transform: translateX(5px);
}

.option-letter {
  display: inline-block;
  width: 50px;
  height: 50px;
  line-height: 50px;
  background: #4a90e2;
  color: white;
  border-radius: 50%;
  font-weight: bold;
  font-size: 24px;
  margin-right: 20px;
  flex-shrink: 0;
  text-align: center;
}

.quiz-option:hover .option-letter {
  background: white;
  color: #4a90e2;
}

.option-text {
  flex: 1;
  font-size: 22px;
}

/* Answer highlight states */
.quiz-option.selected-wrong {
  background: #f44336 !important;
  border-color: #d32f2f !important;
  color: white !important;
  transform: translateX(0);
}

.quiz-option.selected-wrong .option-letter {
  background: white !important;
  color: #f44336 !important;
}

.quiz-option.correct-answer {
  background: #2196F3 !important;
  border-color: #1976D2 !important;
  color: white !important;
  transform: translateX(0);
}

.quiz-option.correct-answer .option-letter {
  background: white !important;
  color: #2196F3 !important;
}

/* Feedback Popup */
.feedback-content {
  padding: 60px 40px;
}

.feedback-content h2 {
  font-size: 64px;
  font-weight: bold;
}

.feedback-content.correct {
  background: linear-gradient(135deg, #4caf50 0%, #45a049 100%);
}

.feedback-content.correct h2 {
  color: white;
}

.feedback-content.incorrect {
  background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

.feedback-content.incorrect h2 {
  color: white;
}

/* Penalty Popup */
.penalty-content {
  background: linear-gradient(135deg, #ff9800 0%, #f57c00 100%);
}

.penalty-content h2 {
  color: white;
  font-size: 48px;
  margin-bottom: 25px;
}

.penalty-content p {
  color: white;
  font-size: 28px;
  line-height: 1.6;
}

/* Winner Screen */
#winner-screen {
  background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
}

.winner-container {
  text-align: center;
  padding: 40px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  width: 90%;
}

.winner-container h1 {
  font-size: 52px;
  color: #333;
  margin-bottom: 30px;
  line-height: 1.4;
}

.trophy {
  font-size: 160px;
  margin: 40px 0;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

.play-again-btn {
  padding: 25px 80px;
  font-size: 32px;
  font-weight: bold;
  background: #4caf50;
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.play-again-btn:hover {
  background: #45a049;
  transform: scale(1.05);
}

/* Responsive Design */
@media (max-width: 768px) {
  .menu-container h1 {
    font-size: 36px;
  }

  .player-btn {
    padding: 15px 30px;
    font-size: 18px;
  }

  .start-btn {
    padding: 15px 60px;
    font-size: 22px;
  }

  .board {
    width: 95%;
  }

  .pawn {
    width: 20px;
    height: 20px;
  }

  .turn-indicator {
    font-size: 18px;
    color: white;
  }

  .roll-dice-btn {
    padding: 12px 30px;
    font-size: 16px;
  }

  .quiz-question {
    font-size: 16px;
  }

  .quiz-option {
    padding: 12px 15px;
  }

  .option-text {
    font-size: 14px;
  }

  .winner-container h1 {
    font-size: 24px;
  }

  .trophy {
    font-size: 80px;
  }
}

/* Board Tile Positions - 36 tiles around the board */
/* These will be calculated dynamically in JavaScript based on board layout */
