:root {
  --green: #4caf50;
  --red: #f44336;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #212121;
  --text-secondary: #757575;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* --- Header --- */

.header {
  background: var(--green);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.countdown {
  font-size: 13px;
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

.header-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.header-btn.spinning {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Balance Reset Warning --- */

.reset-warning {
  background: #fff3e0;
  color: #e65100;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  border-bottom: 2px solid #ffcc80;
}

/* --- Balance & Result --- */

.info-bar {
  padding: 16px;
  text-align: center;
}

#balance {
  font-size: 22px;
  font-weight: 700;
}

.result-message {
  font-size: 14px;
  margin-top: 4px;
  min-height: 20px;
  color: var(--text-secondary);
}

.result-message.success {
  color: var(--green);
  font-weight: 600;
}

.result-message.fail {
  color: var(--red);
  font-weight: 600;
}

/* --- Floor List --- */

#floor-list {
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.floor {
  display: flex;
  align-items: center;
  gap: 12px;
}

.floor-label {
  font-size: 18px;
  font-weight: 700;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.floor-machines {
  display: flex;
  gap: 12px;
  flex: 1;
}

/* --- Machine Button --- */

.machine-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 8px;
  border-radius: 12px;
  border: 3px solid var(--green);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: var(--shadow);
  min-height: 100px;
}

.machine-btn.active {
  border-color: var(--red);
}

.machine-btn.idle {
  border-color: var(--green);
}

.machine-btn:active {
  transform: scale(0.95);
}

.machine-icon {
  font-size: 36px;
  line-height: 1;
}

.machine-floor {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.machine-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
  min-height: 20px;
}

/* --- Settings Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal label {
  font-size: 14px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.modal input {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.modal input:focus {
  border-color: var(--green);
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 8px 20px;
  font-size: 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-cancel {
  background: #e0e0e0;
  color: var(--text);
}

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

.btn-cancel:hover {
  background: #d0d0d0;
}

.btn-save:hover {
  background: #43a047;
}

/* --- History Page --- */

.header-back {
  color: #fff;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
}

.history-list {
  padding: 8px 16px 24px;
}

.history-loading,
.history-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 0;
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid #e0e0e0;
}

.history-item-main {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.history-name {
  font-size: 15px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-amount {
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
  flex-shrink: 0;
}

.history-time {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
