@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&family=Playfair+Display:wght@700;800;900&display=swap');

:root {
  /* Surface & Background */
  --bg-page: #EAE7E2;
  --bg-surface: #FFFFFF;
  --bg-elevated: #F5F3F0;
  --bg-overlay: rgba(93, 87, 80, 0.72);

  /* Brand */
  --warm-greige: #C8C4BC;
  --stone-taupe: #B0AAA0;
  --taupe-deep: #8A8278;
  --taupe-darker: #6E675E;

  /* Text */
  --text-primary: #2C2824;
  --text-secondary: #6B6560;
  --text-muted: #9E9890;
  --text-on-dark: #FFFFFF;
  --text-on-accent: #FFFFFF;

  /* Borders */
  --border: #DDD9D3;
  --border-strong: #C8C4BC;

  /* Actions */
  --btn-primary: #7A7268;
  --btn-primary-hover: #6E675E;
  --btn-secondary: #E8E4DE;
  --btn-secondary-hover: #DBD7D0;
  --btn-danger: #B83A2E;
  --btn-danger-hover: #A03228;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(44, 40, 36, 0.06);
  --shadow-md: 0 4px 12px rgba(44, 40, 36, 0.08);
  --shadow-lg: 0 12px 40px rgba(44, 40, 36, 0.12);
  --shadow-xl: 0 20px 60px rgba(44, 40, 36, 0.16);
}

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

body {
  font-family: 'DM Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========== SPIN PAGE ========== */
.spin-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(200, 196, 188, 0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(176, 170, 160, 0.4) 0%, transparent 50%),
    linear-gradient(160deg, #D6D2CA 0%, #C8C4BC 35%, #B8B2A8 65%, #C2BCB2 100%);
}

.title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 8px;
  margin-bottom: 28px;
  color: rgb(138, 130, 120);
  -webkit-text-fill-color: rgb(138, 130, 120);
  text-shadow: 0 2px 4px rgba(44, 40, 36, 0.15);
}

.wheel-container {
  position: relative;
  display: inline-block;
}

canvas#wheelCanvas {
  border-radius: 50%;
  box-shadow:
    0 0 0 6px rgba(255, 255, 255, 0.15),
    0 0 60px rgba(138, 130, 120, 0.3),
    0 12px 40px rgba(44, 40, 36, 0.2);
  width: min(70vh, 80vw);
  height: min(70vh, 80vw);
}

.wheel-pointer {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  filter: drop-shadow(0 4px 10px rgba(44, 40, 36, 0.35));
}

.wheel-pointer svg {
  width: 44px;
  height: 70px;
  display: block;
  transition: transform 0.08s ease;
  transform-origin: center top;
}

.wheel-pointer.wobble svg {
  transform: rotate(15deg);
}

@keyframes pointerBounce {
  0% { transform: rotate(0deg); }
  30% { transform: rotate(18deg); }
  60% { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}

.wheel-pointer.tick svg {
  animation: pointerBounce 0.15s ease;
}

.spin-button {
  margin-top: 20px;
  padding: 18px 64px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text-on-accent);
  background: var(--taupe-deep);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 60px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  box-shadow: var(--shadow-md);
}

.spin-button:hover {
  transform: scale(1.06) translateY(-2px);
  background: var(--taupe-darker);
  box-shadow: var(--shadow-lg);
  border-color: rgba(255, 255, 255, 0.3);
}

.spin-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Result overlay */
.result-display {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.result-display.hidden {
  display: none;
}

.result-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 52px 56px;
  text-align: center;
  animation: popIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
  max-width: 440px;
}

@keyframes popIn {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-content h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.result-content p {
  font-size: 1.35rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  line-height: 1.5;
}

.close-btn {
  padding: 14px 44px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-on-accent);
  background: var(--btn-primary);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.25s ease;
  letter-spacing: 0.5px;
}

.close-btn:hover {
  background: var(--btn-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.admin-link {
  position: fixed;
  bottom: 20px;
  right: 20px;
  color: rgba(255, 255, 255, 0.3);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

.admin-link:hover {
  color: rgba(255, 255, 255, 0.6);
}

/* ========== ADMIN PAGE ========== */
.admin-page {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
}

.tabs {
  display: flex;
  gap: 3px;
  margin-bottom: 28px;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 12px 28px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.tab:hover {
  background: rgba(176, 170, 160, 0.15);
  color: var(--text-secondary);
}

.tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border);
  font-weight: 700;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Positioning tab */
.positioning-split {
  display: flex;
  gap: 25px;
  align-items: flex-start;
}

.positioning-left {
  flex: 1;
  min-width: 0;
}

.positioning-left .card {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

.positioning-right {
  flex: 1;
  min-width: 0;
}

.pos-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  transition: all 0.15s;
}

.pos-item:hover {
  background: var(--bg-surface);
  border-color: var(--border-strong);
}

.pos-item .pos-num {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.pos-item .pos-name {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.pos-item .pos-arrows {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.pos-arrow {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.pos-arrow:hover {
  background: var(--btn-primary);
  color: var(--text-on-accent);
  border-color: var(--btn-primary);
}

.pos-arrow:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.wheel-pointer-preview {
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.wheel-pointer-preview svg {
  width: 30px;
  height: 48px;
  display: block;
}

#previewCanvas {
  border-radius: 50%;
  width: 100%;
  max-width: 400px;
  height: auto;
}

@media (max-width: 900px) {
  .positioning-split { flex-direction: column; }
}

.remark-input {
  padding: 6px 10px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  width: 130px;
  transition: border-color 0.2s;
}

.remark-input:focus {
  outline: none;
  border-color: var(--stone-taupe);
  box-shadow: 0 0 0 3px rgba(176, 170, 160, 0.2);
}

.remark-input::placeholder {
  color: var(--text-muted);
}

.login-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--text-primary);
}

.login-section h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.login-section input {
  padding: 14px 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  width: 300px;
  transition: border-color 0.2s;
}

.login-section input:focus {
  outline: none;
  border-color: var(--stone-taupe);
  box-shadow: 0 0 0 3px rgba(176, 170, 160, 0.2);
}

.admin-section.hidden {
  display: none;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
}

.admin-header div {
  display: flex;
  gap: 8px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin-bottom: 20px;
  font-family: 'DM Sans', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.2px;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="number"] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus {
  outline: none;
  border-color: var(--stone-taupe);
  box-shadow: 0 0 0 3px rgba(176, 170, 160, 0.2);
}

.form-group input[type="color"] {
  height: 42px;
  border: none;
  background: none;
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 24px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--btn-primary);
  color: var(--text-on-accent);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--btn-secondary);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--btn-danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--btn-danger-hover);
}

.btn-small {
  padding: 6px 14px;
  font-size: 0.82rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

td {
  color: var(--text-primary);
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: none;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid var(--border);
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .title { font-size: 2rem; letter-spacing: 4px; }
  canvas#wheelCanvas { width: 320px; height: 320px; }
  .form-row { flex-direction: column; }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .result-content { padding: 36px 28px; margin: 20px; }
}
