:root {
  --bg: #f2f6f3;
  --green: #176b4d;
  --green-dark: #104d38;
  --card: #ffffff;
  --text: #20312a;
  --muted: #718078;
  --border: #dce6df;
  --gold: #f4bd45;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  width: min(1400px, 100%);
  margin: 0 auto;
}

header {
  margin-bottom: 24px;
  text-align: center;
}

h1 {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: clamp(1.7rem, 4vw, 2.4rem);
}

header p {
  margin: 0;
  color: var(--muted);
}

/* Papan dan panel permainan */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  align-items: start;
  width: 100%;
}

.board-wrap {
  width: 100%;
  min-width: 0;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(32, 49, 42, 0.07);
}

.board {
  display: grid;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(10, minmax(0, 1fr));
  gap: 6px;
  padding: 12px;
}

/* Kotak-kotak papan */
.tile {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 7px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fbfdfb;
}

.tile.current {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px #f4bd4530;
}

.tile-name {
  font-size: clamp(0.5rem, 1vw, 0.82rem);
  font-weight: 750;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tile-info {
  color: var(--muted);
  font-size: clamp(0.45rem, 0.85vw, 0.72rem);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tile-owner {
  color: var(--green);
  font-size: clamp(0.45rem, 0.8vw, 0.7rem);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.token {
  font-size: 1rem;
}

/* Panel */
.panel {
  width: 100%;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 8px 24px rgba(32, 49, 42, 0.07);
}

.panel h2 {
  margin: 0;
}

.players {
  display: grid;
  gap: 10px;
  margin: 14px 0 18px;
}

.player-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fbfdfb;
}

.player-card.active {
  border-color: var(--green);
  background: #eff8f2;
}

.player-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 750;
}

.player-money {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Tombol */
button {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #ffffff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

button:hover:not(:disabled) {
  background: var(--green-dark);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary {
  margin-top: 9px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
}

button.secondary:hover:not(:disabled) {
  background: #f4f7f5;
}

/* Status permainan */
.status {
  min-height: 58px;
  margin: 14px 0;
  padding: 12px;
  border-radius: 10px;
  background: #f4f7f5;
  color: #40534a;
  line-height: 1.45;
}

/* Form soal */
.question {
  display: none;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.question.visible {
  display: block;
}

.question p {
  margin: 0 0 10px;
  font-weight: 700;
}

.answer-row {
  display: flex;
  gap: 8px;
}

input {
  min-width: 0;
  flex: 1;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
}

input:focus {
  outline: 2px solid #176b4d40;
  border-color: var(--green);
}

.answer-row button {
  width: auto;
}

.hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Popup kartu komunitas */
.community-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: rgba(0, 80, 40, 0.55);
}

.community-box {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 16px;
  background: #075b32;
  color: #ffffff;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.community-box h2 {
  margin: 0 0 12px;
}

.community-box p {
  margin: 0 0 22px;
  line-height: 1.5;
}

.community-box button {
  width: auto;
  padding: 10px 28px;
  background: #ffffff;
  color: #075b32;
}

.community-box button:hover:not(:disabled) {
  background: #eaf5ee;
}

/* Popup tantangan */
.popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.65);
}

.popup-card {
  width: min(500px, 100%);
  padding: 24px;
  border-radius: 14px;
  background: #ffffff;
  color: #222222;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.popup-card h2 {
  margin-top: 0;
}

#challengeOptions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.challenge-option {
  padding: 12px;
  border: 1px solid #bbbbbb;
  border-radius: 8px;
  background: #f5f5f5;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.challenge-option:hover:not(:disabled) {
  background: #e5efff;
}

.challenge-option:disabled {
  cursor: default;
}

#challengeFeedback {
  min-height: 24px;
  font-weight: 700;
}

/* Tablet dan ponsel */
@media (max-width: 600px) {
  body {
    padding: 14px;
  }

  header {
    margin-bottom: 18px;
  }

  .layout {
    gap: 14px;
  }

  .board {
    gap: 3px;
    padding: 6px;
  }

  .tile {
    padding: 3px;
    border-width: 1px;
    border-radius: 5px;
  }

  .tile-name {
    font-size: clamp(0.4rem, 1.8vw, 0.65rem);
  }

  .tile-info,
  .tile-owner {
    font-size: clamp(0.38rem, 1.5vw, 0.58rem);
  }

  .token {
    font-size: 0.75rem;
  }

  .panel {
    padding: 16px;
  }
}
