/* 大富翁 4 風格網頁版 */

:root {
  --wood-1: #d4a574;
  --wood-2: #b8895c;
  --wood-3: #8b6239;
  --paper: #f7ecd6;
  --ink: #3a2a1a;
  --gold: #f3c249;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);

  --red: #e63946;
  --blue: #2a6df4;
  --green: #2a9d4a;
  --yellow: #e8b53a;
}

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

html, body {
  height: 100%;
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  color: var(--ink);
  overflow: hidden;
}

body {
  background:
    radial-gradient(ellipse at top, #6b4426 0%, #3a2415 60%, #1a0f08 100%);
  min-height: 100vh;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

h1 {
  text-align: center;
  font-family: 'Ma Shan Zheng', 'Noto Sans TC', cursive;
  font-size: 32px;
  color: var(--gold);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
  letter-spacing: 4px;
}

.game-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 12px;
  min-height: 0;
}

.board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

/* === 棋盤 === */
.board {
  --cell: min(11.5vh, calc((100vw - 320px) / 9));
  width: calc(var(--cell) * 7);
  height: calc(var(--cell) * 7);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  background: linear-gradient(135deg, var(--wood-1), var(--wood-2));
  border: 6px solid var(--wood-3);
  border-radius: 8px;
  box-shadow: var(--shadow), inset 0 0 30px rgba(0, 0, 0, 0.3);
  position: relative;
  padding: 2px;
}

.tile {
  background: var(--paper);
  border: 1px solid #b89060;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  position: relative;
  font-size: 10px;
  overflow: hidden;
  cursor: default;
  transition: box-shadow 0.2s;
}

.tile.zone-stripe::before {
  content: '';
  display: block;
  height: 22%;
  width: 100%;
}
.tile.zone-red::before    { background: var(--red); }
.tile.zone-blue::before   { background: var(--blue); }
.tile.zone-green::before  { background: var(--green); }
.tile.zone-yellow::before { background: var(--yellow); }

.tile-name {
  font-weight: 600;
  text-align: center;
  padding: 2px 1px 0;
  font-size: clamp(9px, 1.1vh, 13px);
  line-height: 1.1;
}

.tile-price {
  text-align: center;
  font-size: clamp(8px, 0.9vh, 11px);
  color: #555;
  margin-top: auto;
  padding: 1px;
}

.tile-level {
  text-align: center;
  font-size: clamp(9px, 1vh, 12px);
  letter-spacing: -1px;
}

.tile-corner {
  background: linear-gradient(135deg, #fff8e0, #f3d784);
  align-items: center;
  justify-content: center;
}
.tile-corner .tile-name {
  font-size: clamp(11px, 1.4vh, 16px);
  font-weight: 700;
}
.tile-corner .tile-icon {
  font-size: clamp(18px, 2.5vh, 28px);
}

.tile-special {
  align-items: center;
  justify-content: center;
}
.tile-special .tile-icon {
  font-size: clamp(16px, 2vh, 24px);
}
.tile-special .tile-name {
  font-size: clamp(9px, 1vh, 12px);
}
.tile-special.t-chance { background: linear-gradient(180deg, #ffebb0, #fdd66c); }
.tile-special.t-fate   { background: linear-gradient(180deg, #ffd0d0, #ff9090); }
.tile-special.t-tax    { background: linear-gradient(180deg, #d4d4d4, #a8a8a8); }

.tile.owned-0 { box-shadow: inset 0 0 0 3px var(--red); }
.tile.owned-1 { box-shadow: inset 0 0 0 3px var(--blue); }
.tile.owned-2 { box-shadow: inset 0 0 0 3px var(--green); }
.tile.owned-3 { box-shadow: inset 0 0 0 3px var(--yellow); }

@keyframes goldFlash {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 24px 4px var(--gold); }
}
.tile.flash {
  animation: goldFlash 0.6s ease 2;
}

/* 中央區 */
.center-area {
  position: absolute;
  left: calc(var(--cell) * 1 + 2px);
  top: calc(var(--cell) * 1 + 2px);
  width: calc(var(--cell) * 5);
  height: calc(var(--cell) * 5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  pointer-events: none;
}

.center-title {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: clamp(28px, 5vh, 56px);
  color: var(--wood-3);
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.4);
  letter-spacing: 6px;
}

/* 骰子 */
.dice-tray {
  display: flex;
  gap: 12px;
  perspective: 600px;
}
.die {
  width: clamp(36px, 5vh, 56px);
  height: clamp(36px, 5vh, 56px);
  background: #fff;
  border-radius: 8px;
  border: 2px solid #888;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(20px, 3vh, 32px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.1);
  transition: transform 0.1s;
}
.die.rolling {
  animation: rollDie 0.6s linear;
}
@keyframes rollDie {
  0%   { transform: rotateX(0deg) rotateY(0deg); }
  25%  { transform: rotateX(180deg) rotateY(90deg); }
  50%  { transform: rotateX(360deg) rotateY(180deg); }
  75%  { transform: rotateX(540deg) rotateY(270deg); }
  100% { transform: rotateX(720deg) rotateY(360deg); }
}

/* 卡片動畫 */
.card-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: clamp(180px, 32vh, 260px);
  background: linear-gradient(180deg, #fffbe8, #f4d56b);
  border: 3px solid var(--wood-3);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  z-index: 50;
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.22, 1.4, 0.36, 1), opacity 0.3s;
}
.card-popup.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}
.card-deck {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 18px;
  color: var(--wood-3);
}
.card-title {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0;
}
.card-desc {
  font-size: 14px;
  color: #444;
}

/* === 玩家代幣 === */
.token {
  position: absolute;
  width: calc(var(--cell) * 0.32);
  height: calc(var(--cell) * 0.32);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cell) * 0.18);
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: left 0.2s ease, top 0.2s ease;
  pointer-events: none;
}
.token.bankrupt {
  filter: grayscale(1) brightness(0.7);
  opacity: 0.5;
}

/* === 側邊面板 === */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.players-panel {
  background: var(--paper);
  border-radius: 8px;
  padding: 8px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-card {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid transparent;
  align-items: center;
  transition: all 0.2s;
}
.player-card.active {
  border-color: var(--gold);
  background: #fff7d8;
  box-shadow: 0 0 12px rgba(243, 194, 73, 0.5);
}
.player-card.bankrupt {
  filter: grayscale(1);
  opacity: 0.5;
}
.player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.player-info {
  font-size: 12px;
  line-height: 1.3;
}
.player-name {
  font-weight: 700;
  font-size: 13px;
}
.player-cash {
  color: #2a6d2a;
  font-weight: 600;
}
.player-estates {
  color: #555;
}

.actions-panel {
  background: var(--paper);
  border-radius: 8px;
  padding: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.actions-panel button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px;
  border: 2px solid var(--wood-3);
  border-radius: 6px;
  background: linear-gradient(180deg, #ffd45f, #e6a020);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.1s, box-shadow 0.1s;
}
.actions-panel button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.actions-panel button:active:not(:disabled) {
  transform: translateY(1px);
}
.actions-panel button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.actions-panel button.secondary {
  background: linear-gradient(180deg, #ddd, #aaa);
}

.log-panel {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  padding: 8px;
  overflow-y: auto;
  color: #f3e6c8;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column-reverse;
}
.log-entry {
  padding: 2px 4px;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}
.log-entry:first-child {
  color: var(--gold);
  font-weight: 600;
}

/* 結束畫面 */
.game-over {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.game-over-card {
  background: var(--paper);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  border: 4px solid var(--gold);
}
.game-over-card h2 {
  font-family: 'Ma Shan Zheng', cursive;
  font-size: 36px;
  margin-bottom: 12px;
  color: var(--wood-3);
}
.game-over-card p {
  font-size: 18px;
  margin-bottom: 20px;
}
.game-over-card button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background: var(--gold);
  cursor: pointer;
}

/* RWD：手機橫向 */
@media (max-width: 720px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .side-panel {
    flex-direction: row;
    height: auto;
  }
  .players-panel {
    flex: 2;
  }
  .actions-panel {
    flex: 1;
    min-width: 140px;
  }
  .log-panel {
    display: none;
  }
  .board {
    --cell: min(13vw, 13vh);
  }
  h1 { font-size: 22px; }
}
