:root {
  --bg: #1abc9c;
  --bg-dark: #16a085;
  --panel: #ffffff;
  --text: #2c3e50;
  --danger: #e74c3c;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button, input { font-family: inherit; }

/* ---------- login / modal ---------- */
.login-overlay {
  position: fixed; inset: 0;
  background: rgba(22, 160, 133, 0.97);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 16px;
}
.login-card {
  background: var(--panel);
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 340px;
  max-width: 100%;
}
.login-card h1 { margin-bottom: 8px; }
.login-card p { color: #7f8c8d; margin-bottom: 20px; }
.login-card input {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 2px solid #dfe6e9; border-radius: 10px;
  outline: none; text-align: center;
}
.login-card input:focus { border-color: var(--bg); }
.login-card button {
  margin-top: 12px; width: 100%; padding: 12px;
  font-size: 16px; font-weight: 700; color: #fff;
  background: var(--bg); border: none; border-radius: 10px;
  cursor: pointer;
}
.login-card button:hover { background: var(--bg-dark); }
.login-card .ghost-btn {
  background: transparent; color: #7f8c8d;
  border: 2px solid #dfe6e9; font-weight: 600;
}

/* ---------- header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px;
  background: #17202a; color: #fff;
}
.brand { font-size: 20px; font-weight: 700; }
.player-badge { font-size: 14px; opacity: 0.9; }
.player-badge .admin-tag,
.player-list .admin-tag {
  background: #f39c12; color: #17202a;
  padding: 2px 8px; border-radius: 6px; font-weight: 700; margin-left: 8px;
  font-size: 11px;
}

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}
.admin-panel { grid-column: 1 / -1; }

.side {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ---------- wheel ---------- */
.wheel-area {
  display: flex; flex-direction: column; align-items: center;
  position: relative;
  padding-top: 32px;
}
.pointer {
  width: 0; height: 0;
  border-left: 22px solid transparent;
  border-right: 22px solid transparent;
  border-top: 36px solid #f1c40f;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.3));
  z-index: 5;
  margin-bottom: -18px;
}
#wheelWrap {
  width: min(560px, 92vw);
  aspect-ratio: 1;
  cursor: pointer;
  touch-action: manipulation;
}
#wheel { width: 100%; height: 100%; display: block; }

#spinBtn {
  margin-top: 26px;
  padding: 15px 56px;
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  color: #fff; background: #e67e22;
  border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 0 #b3541e;
  transition: transform 0.1s, box-shadow 0.1s;
  touch-action: manipulation;
}
#spinBtn:hover:not(:disabled) { transform: translateY(2px); box-shadow: 0 4px 0 #b3541e; }
#spinBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-line { margin-top: 10px; color: #0e6655; font-weight: 600; min-height: 22px; text-align: center; }

.result-banner {
  margin-top: 12px;
  background: #fff; color: #17202a;
  font-size: 22px; font-weight: 800;
  padding: 14px 32px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  animation: pop 0.35s ease;
  text-align: center;
  max-width: 100%;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- side cards ---------- */
.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.card h2 { font-size: 17px; margin-bottom: 16px; }
.card .hint { font-size: 12.5px; color: #7f8c8d; margin-bottom: 14px; line-height: 1.55; }

.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row input {
  flex: 1; min-width: 0; padding: 9px 12px;
  border: 2px solid #dfe6e9; border-radius: 8px;
  outline: none; font-size: 14px;
}
.add-row input:focus { border-color: var(--bg); }
.add-row button {
  width: 40px; flex-shrink: 0; font-size: 20px; font-weight: 700;
  background: var(--bg); color: #fff; border: none; border-radius: 8px; cursor: pointer;
}
.add-row button:hover { background: var(--bg-dark); }

.entry-list { list-style: none; }
.entry-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px; border-bottom: 1px solid #f0f3f4; font-size: 14px;
  line-height: 1.4;
}
.entry-label { overflow-wrap: anywhere; }
.entry-dot { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0; }
.entry-chance { margin-left: auto; font-size: 12px; color: #95a5a6; flex-shrink: 0; }

.player-list, .history-list { list-style: none; font-size: 14px; }
.player-list li { padding: 7px 0; }
.player-list li + li { border-top: 1px solid #f0f3f4; }
.history-list li { padding: 8px 0; border-bottom: 1px solid #f0f3f4; line-height: 1.4; }
.history-list li:last-child { border-bottom: none; }
.history-list .by { color: #95a5a6; font-size: 12px; }
.entry-list li:last-child { border-bottom: none; }
.empty { color: #b2bec3; font-size: 13px; font-style: italic; }

/* ---------- admin ---------- */
.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 420px; }
.admin-table th { text-align: left; color: #7f8c8d; font-size: 12px; padding: 6px 4px; }
.admin-table td { padding: 6px 4px; border-top: 1px solid #f0f3f4; }
.admin-table input[type="number"] {
  width: 76px; padding: 6px 8px; border: 2px solid #dfe6e9; border-radius: 6px;
  font-size: 14px;
}
.admin-table input[type="number"]:focus { border-color: #f39c12; outline: none; }
.admin-table .remove-btn {
  background: var(--danger); color: #fff; border: none;
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 12px;
}
.admin-actions { margin-top: 14px; display: flex; gap: 10px; }
.admin-actions .danger {
  background: var(--danger); color: #fff; border: none;
  border-radius: 8px; padding: 10px 18px; cursor: pointer; font-weight: 600;
}

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #17202a; color: #fff; padding: 12px 24px;
  border-radius: 10px; font-size: 14px; z-index: 200;
  animation: pop 0.25s ease;
  max-width: 92vw; text-align: center;
}
.hidden { display: none !important; }

/* ---------- tablet ---------- */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; padding: 16px; gap: 20px; }
  .side { order: 2; gap: 16px; }
}

/* ---------- HP ---------- */
@media (max-width: 480px) {
  header { padding: 12px 16px; }
  .brand { font-size: 16px; }
  .player-badge { font-size: 12px; }

  main { padding: 12px; gap: 16px; }
  .side { gap: 14px; }

  .wheel-area { padding-top: 18px; }
  .pointer {
    border-left-width: 16px;
    border-right-width: 16px;
    border-top-width: 27px;
    margin-bottom: -15px;
  }
  #wheelWrap { width: 94vw; }

  #spinBtn { margin-top: 18px; padding: 13px 44px; font-size: 18px; }
  .status-line { font-size: 13px; }
  .result-banner { font-size: 17px; padding: 12px 20px; }

  .card { padding: 16px; border-radius: 12px; }
  .card h2 { font-size: 15px; margin-bottom: 12px; }
  .add-row input { font-size: 16px; } /* cegah auto-zoom iOS */
  .add-row button { width: 42px; }

  .login-card { padding: 28px 22px; }

  .admin-table { min-width: 360px; font-size: 12px; }
  .admin-table th, .admin-table td { padding: 6px 4px; }
  .admin-table input[type="number"] { width: 56px; padding: 5px 6px; font-size: 14px; }
  .admin-table .remove-btn { padding: 5px 9px; }

  .toast { bottom: 14px; padding: 10px 18px; font-size: 13px; }
}
