:root {
  --bg: #1b1410;
  --panel: #2a201a;
  --panel2: #34281f;
  --accent: #c8893a;
  --accent2: #e0a85a;
  --text: #f3e9dd;
  --muted: #b09a85;
  --green: #4caf6d;
  --red: #d4604f;
  --line: #4a3a2d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 50% -10%, #3a2c20, var(--bg));
  color: var(--text);
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 22px; margin: 0; }

h2 { margin-top: 0; }

.card {
  max-width: 420px;
  margin: 48px auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(0,0,0,.4);
}

label { display: block; margin: 16px 0 4px; font-size: 14px; color: var(--muted); }
input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 16px;
}
input:focus { outline: 2px solid var(--accent); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; }

button {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  font-size: 15px;
  padding: 11px 16px;
  font-weight: 600;
  transition: filter .15s, transform .05s;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
.primary { background: var(--accent); color: #1b120a; width: 100%; margin-top: 18px; }
.primary:hover:not(:disabled) { filter: brightness(1.1); }
.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.ghost:hover { filter: brightness(1.2); }
.row .ghost { width: auto; padding: 11px 14px; }

.seg { display: flex; gap: 8px; margin-bottom: 6px; }
.segbtn {
  flex: 1;
  background: var(--panel2);
  color: var(--muted);
  border: 1px solid var(--line);
}
.segbtn.active { background: var(--accent); color: #1b120a; border-color: var(--accent); }

select {
  width: 100%;
  padding: 11px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 15px;
}
select:focus { outline: 2px solid var(--accent); }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.msg { min-height: 20px; font-size: 14px; margin: 10px 0 0; }
.msg.error { color: var(--red); }
.msg.ok { color: var(--green); }

.hidden { display: none !important; }

/* Spilområde */
#gameArea { max-width: 980px; margin: 18px auto; padding: 0 14px; }
.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.pchip {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 2px solid var(--line);
  font-weight: 600;
  font-size: 15px;
}
.pchip.active { border-color: var(--accent2); box-shadow: 0 0 14px rgba(224,168,90,.5); }
.turninfo { font-size: 16px; color: var(--accent2); font-weight: 700; text-align: center; }

.boardwrap { width: 100%; }
canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #2a201a;
  touch-action: manipulation;
}

.controls {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.dice { display: flex; gap: 10px; min-height: 52px; align-items: center; }
.die {
  width: 48px; height: 48px;
  border-radius: 10px;
  background: #f3e9dd;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
  gap: 2px;
  box-shadow: 0 3px 0 #b9a489;
}
.die .pip { width: 100%; height: 100%; border-radius: 50%; background: transparent; }
.die .pip.on { background: #1b120a; }
.die.used { opacity: .3; }
.btns { display: flex; gap: 10px; }
.btns button { width: auto; margin: 0; }

/* Rangliste panel */
.panel {
  position: fixed;
  top: 0; right: 0;
  width: 340px; max-width: 90vw;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  box-shadow: -10px 0 40px rgba(0,0,0,.5);
  z-index: 20;
}
.panelhead { display: flex; justify-content: space-between; align-items: center; }
.panelhead .ghost { width: auto; padding: 6px 12px; }
table { width: 100%; border-collapse: collapse; margin: 14px 0; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; }
td:nth-child(3) { color: var(--accent2); font-weight: 700; }

/* Overlay */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: grid; place-items: center;
  z-index: 30;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px;
  width: 380px; max-width: 90vw;
  text-align: center;
}
.ratings { margin: 14px 0; font-size: 15px; }
.ratings .up { color: var(--green); }
.ratings .down { color: var(--red); }

@media (max-width: 560px) {
  .card { margin: 20px auto; }
  .turninfo { font-size: 13px; }
  .pchip { font-size: 13px; padding: 6px 10px; }
}
