:root {
  --sea-deep: #1a2980;
  --sea-mid: #26d0ce;
  --sea-bright: #00d2ff;
  --sand: #fceabb;
  --coral: #ff6b6b;
  --sun: #f8b500;
  --ink: #2c3e50;
  --panel: rgba(255, 255, 255, 0.95);
  --shadow: rgba(0, 0, 0, 0.25);
  --player: #2ecc71;
  --enemy: #e74c3c;
  --highlight: rgba(241, 196, 15, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Poppins", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(to bottom right, var(--sea-deep), var(--sea-mid));
  overflow-x: hidden;
}

/* Lobby */
.lobby-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: white;
  text-align: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(255,255,255,0.1) 0%, transparent 70%);
  animation: fadeIn 1s ease;
}

.lobby-screen h1 {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  text-shadow: 0 4px 10px rgba(0,0,0,0.3);
  background: -webkit-linear-gradient(top, #fff, #cceeff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lobby-screen p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.lobby-screen input {
  padding: 15px;
  border-radius: 50px;
  border: 2px solid rgba(255,255,255,0.3);
  background: rgba(0,0,0,0.2);
  color: white;
  margin: 10px 0 20px;
  font-size: 1.2rem;
  width: 100%;
  max-width: 320px;
  text-align: center;
  transition: all 0.3s;
}

.lobby-screen input:focus {
    outline: none;
    background: rgba(0,0,0,0.4);
    border-color: var(--sea-bright);
}

.lobby-screen input::placeholder {
    color: rgba(255,255,255,0.6);
}

.lobby-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 320px;
}

/* Game Stage */
.sea-stage {
  max-width: 1200px;
  margin: 0 auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 250px; /* Ensure space for fixed hand on all devices */
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  color: white;
  margin-bottom: 20px;
  gap: 15px;
  background: rgba(0,0,0,0.2);
  padding: 10px 20px;
  border-radius: 15px;
  backdrop-filter: blur(5px);
}

.brand h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 1px;
}

.btn-audio {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.2s;
}

.btn-audio:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: scale(1.1);
}

.status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.status-block {
  background: rgba(255,255,255,0.15);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid rgba(255,255,255,0.1);
}

.arena {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
  flex-grow: 1;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px;
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
}

.lane {
  display: grid;
  grid-template-columns: 1fr 50px 1fr;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
  padding: 10px;
  border-radius: 15px;
  align-items: center;
  position: relative;
}

.lane-divider {
  color: rgba(255,255,255,0.5);
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slot {
  height: 160px;
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  background: rgba(255,255,255,0.02);
}

.slot.is-highlight {
  background: var(--highlight);
  border-color: var(--sun);
  box-shadow: 0 0 15px var(--sun);
  transform: scale(1.02);
}

/* Cards */
.card {
  width: 140px;
  height: 200px;
  background-color: #fff;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  box-shadow: 0 8px 15px rgba(0,0,0,0.2);
  cursor: grab;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.card:active {
    cursor: grabbing;
}

.card-art {
  height: 100px;
  background-color: #eee;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  margin-bottom: 4px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

/* Board cards hover - keep original behavior */
.slot .card:hover {
  transform: translateY(-8px) scale(1.02);
  z-index: 10;
  box-shadow: 0 12px 20px rgba(0,0,0,0.3);
}

.card.dragging {
    opacity: 0.5;
}

.card-art {
  height: 80px;
  background-color: #eee;
  border-radius: 8px;
  background-size: cover;
  background-position: center;
  margin-bottom: 4px;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.card__title { 
    font-weight: 700; 
    font-size: 0.9rem; 
    color: var(--ink);
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

.card-badge {
    font-size: 1.1rem;
    margin-left: 4px;
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
    color: var(--sun);
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Bubbles Animation */
.bubble {
    position: absolute;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), rgba(150, 200, 255, 0.4));
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 
        inset 0 0 10px rgba(255, 255, 255, 0.5),
        0 0 10px rgba(100, 150, 255, 0.3);
    animation: float-up 3s ease-in forwards;
    opacity: 0.8;
}

@keyframes float-up {
    0% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-100px) translateX(var(--drift, 0px)) scale(1.1);
        opacity: 0.6;
    }
    100% {
        transform: translateY(-200px) translateX(var(--drift, 0px)) scale(0.8);
        opacity: 0;
    }
}

.bubbles-effect {
    position: relative;
    overflow: visible;
}

.card__stats { 
    display: flex; 
    justify-content: space-around; 
    font-weight: 800; 
    font-size: 1rem;
    color: #444;
    background: rgba(0,0,0,0.05);
    padding: 5px;
    border-radius: 6px;
}

.card__meta .tag {
    font-size: 0.7rem;
    background: var(--sea-bright);
    color: #fff;
    padding: 2px 6px;
    border-radius: 10px;
    margin-right: 4px;
}

.card__meta .tag--undercatch {
    background: linear-gradient(135deg, #ff6b6b, #ff8e53);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 107, 107, 0.5); }
    50% { box-shadow: 0 0 15px rgba(255, 107, 107, 0.8); }
}

.card__text {
    font-size: 0.7rem;
    color: #666;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.card.is-selected {
  border: 3px solid var(--sun);
  box-shadow: 0 0 0 4px rgba(248, 181, 0, 0.4);
  transform: translateY(-10px);
}

.card--enemy { border-bottom: 4px solid var(--enemy); }
.card--player { border-bottom: 4px solid var(--player); }
.card--ability { background: linear-gradient(to bottom, #fff, #f0faff); }
.card--swimmer { background: linear-gradient(to bottom, #fff, #fffdf0); }


/* Hand */
.hand {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.2); /* Transparent */
  padding: 10px 20px;
  border-top-left-radius: 25px;
  border-top-right-radius: 25px;
  box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
  z-index: 100;
  backdrop-filter: blur(15px); /* Strong blur */
  transition: transform 0.3s ease-in-out;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.hand.collapsed {
  transform: translateY(calc(100% - 30px)); /* Only show a small tab/handle */
}

.btn-toggle-hand {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.3);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 60px;
  height: 24px;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  z-index: 101;
}

.btn-toggle-hand i {
  transition: transform 0.3s ease;
}

.btn-toggle-hand:hover {
  background: rgba(255, 255, 255, 0.5);
  height: 28px;
  top: -28px;
}

.hand-cards {
  display: flex;
  gap: 0;
  overflow-x: visible;
  overflow-y: visible;
  padding: 40px 5px 20px; 
  justify-content: center;
  align-items: flex-end;
  position: relative;
  min-height: 200px;
}

.hand-cards .card {
  margin: 0 -15px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: bottom center;
}

/* Fan effect - each card rotates and positions based on its index */
.hand-cards .card:nth-child(1) { transform: translateY(20px) rotate(-18deg); }
.hand-cards .card:nth-child(2) { transform: translateY(12px) rotate(-12deg); }
.hand-cards .card:nth-child(3) { transform: translateY(6px) rotate(-6deg); }
.hand-cards .card:nth-child(4) { transform: translateY(3px) rotate(-3deg); }
.hand-cards .card:nth-child(5) { transform: translateY(0px) rotate(0deg); }
.hand-cards .card:nth-child(6) { transform: translateY(3px) rotate(3deg); }
.hand-cards .card:nth-child(7) { transform: translateY(6px) rotate(6deg); }
.hand-cards .card:nth-child(8) { transform: translateY(12px) rotate(12deg); }
.hand-cards .card:nth-child(9) { transform: translateY(20px) rotate(18deg); }
.hand-cards .card:nth-child(10) { transform: translateY(25px) rotate(22deg); }

.hand-cards .card:hover {
  transform: translateY(-40px) rotate(0deg) scale(1.15) !important;
  z-index: 100;
  margin: 0 5px;
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.hand-cards .card.is-selected {
  transform: translateY(-35px) rotate(0deg) scale(1.1) !important;
  z-index: 99;
}

.controls {
  position: absolute;
  top: -70px;
  left: 20px;
  right: 100px;
  display: flex;
  gap: 15px;
  z-index: 102;
  justify-content: center;
}

.btn {
  background: linear-gradient(45deg, var(--sun), var(--coral));
  border: none;
  padding: 12px 30px;
  border-radius: 50px;
  color: white;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 1rem;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.btn:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-attack {
  background: linear-gradient(45deg, #d32f2f, #c62828);
  box-shadow: 0 4px 15px rgba(211, 47, 47, 0.5);
}

.btn-attack:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(211, 47, 47, 0.7);
}

.btn-endturn {
  background: linear-gradient(45deg, #f5f5f5, #e0e0e0);
  color: #333;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn-endturn:hover:not(:disabled) {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn-reset {
  position: absolute;
  top: -60px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(45deg, #ff1744, #d50000);
  border: 3px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 23, 68, 0.5);
  transition: all 0.3s;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  animation: pulse-reset 3s ease-in-out infinite;
}

.btn-reset i {
  transition: transform 0.3s ease;
}

.btn-reset:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(255, 23, 68, 0.8);
}

.btn-reset:hover i {
  transform: rotate(180deg);
}

@keyframes pulse-reset {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 23, 68, 0.5); }
  50% { box-shadow: 0 4px 30px rgba(255, 23, 68, 0.8); }
}

.btn-secondary {
    background: linear-gradient(45deg, var(--sea-mid), var(--sea-deep));
    box-shadow: 0 4px 15px rgba(38, 208, 206, 0.4);
}

.hint {
    text-align: center;
    color: var(--ink);
    font-weight: 600;
    margin: 5px 0 0;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8); /* Better readability on transparent bg */
}


/* Panel */
.panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.panel-card {
    background: #0a0a0a; /* Dark terminal screen */
    padding: 15px;
    border-radius: 6px;
    border: 3px solid #333; /* Bezel */
    box-shadow: 
        0 0 0 2px #000, /* Outer edge */
        inset 0 0 15px rgba(0, 0, 0, 0.8); /* Inner shadow */
    font-family: 'Courier New', Courier, monospace;
    color: #33ff00; /* Terminal Green */
    position: relative;
    overflow: hidden;
}

/* Scanline effect */
.panel-card::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        rgba(255, 255, 255, 0) 50%,
        rgba(0, 0, 0, 0.2) 50%,
        rgba(0, 0, 0, 0.2)
    );
    background-size: 100% 4px;
    z-index: 1;
    pointer-events: none;
}

.panel-card h2 {
    margin: 0 0 10px;
    font-size: 0.9rem;
    color: #33ff00;
    border-bottom: 2px solid #33ff00;
    padding-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 4px rgba(51, 255, 0, 0.6);
    position: relative;
    z-index: 2;
}

/* Selected Details Content */
#selectedDetails {
    position: relative;
    z-index: 2;
}

#selectedDetails h3 {
    color: #fff;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.6);
    margin-bottom: 5px;
}

#selectedDetails p {
    color: #33ff00;
    margin: 5px 0;
    line-height: 1.4;
}

.details-empty {
    opacity: 0.6;
    font-style: italic;
}

/* Log Styling */
.log { 
    max-height: 200px; 
    overflow-y: auto; 
    font-size: 0.8rem; 
    position: relative;
    z-index: 2;
}

.log-entry { 
    margin-bottom: 4px; 
    border-bottom: 1px dashed rgba(51, 255, 0, 0.3); 
    padding-bottom: 4px; 
    color: rgba(51, 255, 0, 0.8);
}

.log-entry::before {
    content: "> ";
    margin-right: 5px;
    color: #fff;
}

.log-entry:first-child {
    color: #fff;
    font-weight: bold;
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    background: rgba(51, 255, 0, 0.1);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.4); }

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

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.5s ease;
}

.overlay-content {
  background: white;
  padding: 40px;
  border-radius: 30px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.overlay-content h1 {
  font-size: 3rem;
  margin-bottom: 10px;
  color: var(--sea-deep);
}

.overlay-content p {
  font-size: 1.2rem;
  margin-bottom: 30px;
  color: #666;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Mobile Lane Selector */
.mobile-lane-selector {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  animation: fadeIn 0.2s ease;
}

.lane-selector-content {
  background: linear-gradient(135deg, var(--sea-deep), var(--sea-mid));
  padding: 30px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.2);
}

.lane-selector-content h3 {
  color: white;
  font-size: 1.5rem;
  margin: 0 0 20px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.lane-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 20px;
}

.lane-btn {
  background: linear-gradient(45deg, var(--sun), var(--coral));
  border: none;
  padding: 20px;
  border-radius: 15px;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lane-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 8px rgba(255, 107, 107, 0.6);
}

.cancel-btn {
  background: rgba(255,255,255,0.2);
  border: 2px solid rgba(255,255,255,0.4);
  padding: 12px 40px;
  border-radius: 25px;
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.cancel-btn:active {
  background: rgba(255,255,255,0.3);
}

/* Media Queries */
@media (max-width: 900px) {
    .brand h1, .brand .tagline, .brand .kicker { display: none; } /* Hide title on mobile */
    
    .arena { grid-template-columns: 1fr; display: flex; flex-direction: column-reverse; width: 100%; }
    .board { width: 100%; padding: 5px; }
    
    .panel { 
        display: flex; 
        flex-direction: row; 
        gap: 10px; 
        width: 100%; 
        font-size: 0.8rem;
        margin-bottom: 10px;
    }
    
    .panel-card {
        flex: 1;
        padding: 8px;
        min-height: 80px;
        max-height: 100px;
        overflow-y: auto;
    }
    
    .log { font-size: 0.75rem; }
    .log-entry { padding: 2px 0; }
    
    .panel-card h2 { font-size: 0.8rem; margin-bottom: 4px; }
    
    .topbar { padding: 6px 12px; margin-bottom: 5px; gap: 5px; }
}

@media (max-width: 768px) {
    .lobby-screen h1 { font-size: 2.5rem; }
    
    .lane {
        grid-template-columns: 1fr 30px 1fr;
        padding: 6px;
        gap: 6px;
    }
    
    .lane-divider { font-size: 0.6rem; }
    
    .slot { height: 120px; }
    
    .hand {
        padding: 10px;
    }
    
    .hand-cards {
        overflow-x: auto;
        padding: 30px 10px 15px;
        min-height: 160px;
    }
    
    /* Adjust fan angles for mobile - tighter spread */
    .hand-cards .card:nth-child(1) { transform: translateY(15px) rotate(-15deg); }
    .hand-cards .card:nth-child(2) { transform: translateY(10px) rotate(-10deg); }
    .hand-cards .card:nth-child(3) { transform: translateY(5px) rotate(-5deg); }
    .hand-cards .card:nth-child(4) { transform: translateY(2px) rotate(-2deg); }
    .hand-cards .card:nth-child(5) { transform: translateY(0px) rotate(0deg); }
    .hand-cards .card:nth-child(6) { transform: translateY(2px) rotate(2deg); }
    .hand-cards .card:nth-child(7) { transform: translateY(5px) rotate(5deg); }
    .hand-cards .card:nth-child(8) { transform: translateY(10px) rotate(10deg); }
    .hand-cards .card:nth-child(9) { transform: translateY(15px) rotate(15deg); }
    .hand-cards .card:nth-child(10) { transform: translateY(18px) rotate(18deg); }
    
    .hand-cards .card {
        margin: 0 -20px;
    }
    
    .hand-cards .card:hover {
        transform: translateY(-30px) rotate(0deg) scale(1.1) !important;
    }
    
    .controls {
        top: -60px;
        right: 100px;
        left: 10px;
        justify-content: center;
    }
    
    .btn-reset {
        top: -55px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    
    .btn { padding: 10px 20px; font-size: 0.9rem; }
}