/* Norsu.css - Shared styles for all pages */

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

html {
  height: -webkit-fill-available;
}

body {
  font-family: 'Nunito', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  color: #333;
  overflow-x: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.container {
  max-width: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== SCREEN MANAGEMENT ===== */
.screen {
  display: none;
  width: 100%;
  max-width: 900px;
  animation: fadeIn 0.4s ease-in;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ===== LOGIN SCREEN ===== */
#loginScreen {
  background: white;
  border-radius: 20px;
  padding: 40px 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
  max-height: 95vh;
  max-height: 95dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.login-title {
  font-size: 48px;
  font-weight: 800;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 16px;
  color: #999;
  margin-bottom: 12px;
}

.player-count-badge {
  font-size: 13px;
  color: #b0b0b0;
  margin-bottom: 28px;
}

.avatar-selector {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 30px;
}

.avatar-btn {
  width: 56px;
  height: 56px;
  border: 3px solid transparent;
  border-radius: 50%;
  font-size: 28px;
  cursor: pointer;
  transition: all 0.3s;
  background: #f5f5f5;
}

.avatar-btn:hover {
  transform: scale(1.1);
}

.avatar-btn.selected {
  border-color: #667eea;
  background: #f0f0ff;
  transform: scale(1.15);
}

.name-input {
  width: 100%;
  padding: 15px 20px;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  font-size: 16px;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 20px;
  transition: border-color 0.3s;
}

.name-input:focus {
  outline: none;
  border-color: #667eea;
}

.login-btn,
.button-primary {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 10px;
}

.login-btn:hover,
.button-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.login-btn:active,
.button-primary:active {
  transform: translateY(0);
}

.button-secondary {
  width: 100%;
  padding: 15px;
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Nunito', sans-serif;
  margin-bottom: 10px;
}

.button-secondary:hover {
  background: #f8f8ff;
  transform: translateY(-2px);
}

.button-secondary:active {
  transform: translateY(0);
}

.button-back {
  padding: 10px 20px;
  background: #f5f5f5;
  color: #666;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
}

.button-back:hover {
  background: #e8e8e8;
  color: #333;
}

/* ===== EMOJI PASSWORD ===== */
.login-step {
  display: none;
}
.login-step.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.login-step-title {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin-bottom: 6px;
}

.login-step-hint {
  font-size: 13px;
  color: #999;
  margin-bottom: 18px;
}

.emoji-pin-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
  min-height: 58px;
}

.emoji-pin-slot {
  width: 52px;
  height: 52px;
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: #fafafa;
  transition: all 0.2s;
}

.emoji-pin-slot.filled {
  border-color: #667eea;
  background: #f0f0ff;
  animation: pinPop 0.25s ease;
}

@keyframes pinPop {
  0% { transform: scale(0.8); }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.emoji-keyboard {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.emoji-key {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: 26px;
  cursor: pointer;
  background: #f5f5f5;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.emoji-key:hover {
  transform: scale(1.12);
  background: #eee;
}

.emoji-key:active {
  transform: scale(0.95);
}

.pin-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 12px;
}

.pin-back-btn {
  padding: 8px 18px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  background: white;
  color: #666;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Nunito', sans-serif;
  transition: all 0.2s;
}

.pin-back-btn:hover {
  border-color: #667eea;
  color: #667eea;
}

.player-list {
  margin-top: 15px;
}

.player-list-title {
  font-size: 14px;
  color: #999;
  font-weight: 600;
  margin-bottom: 10px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.player-card:hover {
  border-color: #667eea;
  background: #f8f8ff;
  transform: translateX(4px);
}

.player-card-avatar {
  font-size: 32px;
}

.player-card-info {
  flex: 1;
  min-width: 0;
}

.player-card-name {
  font-size: 16px;
  font-weight: 700;
  color: #333;
}

.player-card-medals {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.card-medal {
  font-size: 12px;
  font-weight: 700;
  color: #555;
  background: #f0f0f0;
  padding: 1px 6px;
  border-radius: 8px;
  white-space: nowrap;
}

.card-medal-empty {
  color: #bbb;
  font-weight: 600;
  font-size: 11px;
}

.card-medal-hidden {
  color: #bbb;
  font-style: italic;
  font-size: 11px;
  background: none;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  margin-bottom: 8px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  color: #333;
}

.settings-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: #ddd;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-switch.active {
  background: #4ecdc4;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch.active::after {
  transform: translateX(22px);
}

.pin-error {
  color: #e74c3c;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  min-height: 22px;
  animation: wrongShake 0.4s ease;
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.player-card-settings {
  margin-left: auto;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #ccc;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.player-card-settings:hover {
  background: #f0f0ff;
  color: #667eea;
}

.settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.settings-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.settings-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  width: 90%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.settings-card-avatar {
  font-size: 48px;
}

.settings-card-name {
  font-size: 18px;
  font-weight: 700;
  color: #333;
  margin: 4px 0 18px;
}

.settings-menu-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 8px;
  border: 2px solid #e8e8e8;
  border-radius: 12px;
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #333;
}

.settings-menu-btn:hover {
  border-color: #667eea;
  background: #f8f8ff;
}

.settings-menu-btn.danger {
  color: #e74c3c;
  border-color: #fdecea;
}

.settings-menu-btn.danger:hover {
  background: #fdecea;
  border-color: #e74c3c;
}

.settings-cancel-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-cancel-btn:hover {
  background: #f5f5f5;
  color: #666;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #ccc;
  font-size: 13px;
  font-weight: 600;
}

.or-divider::before,
.or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e0e0e0;
}

/* ===== RANKING OVERLAY ===== */
.ranking-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.ranking-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.ranking-card {
  background: #fff;
  border-radius: 20px;
  padding: 24px 20px;
  width: 92%;
  max-width: 400px;
  max-height: 85vh;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
}

.ranking-title {
  font-size: 22px;
  font-weight: 800;
  color: #333;
  margin-bottom: 8px;
}

.ranking-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  background: #f0f0f0;
  border-radius: 10px;
  padding: 3px;
}
.ranking-tab {
  flex: 1;
  padding: 7px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  transition: all 0.2s;
}
.ranking-tab.active {
  background: #fff;
  color: #333;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.ranking-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}

.ranking-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  background: #f8f8ff;
  transition: background 0.2s;
}

.ranking-row:first-child {
  background: linear-gradient(135deg, #fff8e1, #fff3cd);
  border: 2px solid #ffd54f;
}

.ranking-pos {
  font-size: 16px;
  font-weight: 800;
  color: #999;
  min-width: 28px;
  text-align: center;
}

.ranking-row:first-child .ranking-pos {
  color: #f9a825;
}

.ranking-avatar {
  font-size: 28px;
}

.ranking-info {
  flex: 1;
  text-align: left;
}

.ranking-name {
  font-size: 15px;
  font-weight: 700;
  color: #333;
}

.ranking-medals {
  display: flex;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.ranking-medal-item {
  font-size: 12px;
  font-weight: 600;
  color: #666;
}

.ranking-stats {
  display: inline;
  font-size: 11px;
  color: #999;
  margin-left: 8px;
}

.ranking-score {
  position: relative;
  min-width: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ranking-score-rosette {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ranking-score-rosette svg {
  width: 52px;
  height: 52px;
}
.ranking-score-number {
  position: relative;
  z-index: 1;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  line-height: 1;
}
.ranking-score-label {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 7px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
}

.ranking-empty {
  padding: 30px 10px;
  color: #999;
  font-size: 14px;
}

.ranking-loading {
  padding: 30px 10px;
  color: #999;
  font-size: 14px;
}

.ranking-close-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: transparent;
  font-size: 14px;
  color: #999;
  cursor: pointer;
  transition: all 0.2s;
}

.ranking-close-btn:hover {
  background: #f5f5f5;
  color: #666;
}

.ranking-btn {
  font-size: 0.95em;
  padding: 10px 20px;
  background: linear-gradient(135deg, #f9a825, #ff8f00);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.ranking-btn:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 15px rgba(249,168,37,0.4);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .avatar-selector {
    grid-template-columns: repeat(5, 1fr);
  }

  .emoji-keyboard {
    grid-template-columns: repeat(5, 1fr);
  }
}
